mongoid-encryptor 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +7 -0
 - data/LICENSE +20 -0
 - data/README.md +145 -0
 - data/lib/mongoid/encryptor/version.rb +7 -0
 - data/lib/mongoid/encryptor.rb +72 -0
 - data/spec/asymmetric_encryption_spec.rb +27 -0
 - data/spec/encrypted_attributes_spec.rb +11 -0
 - data/spec/keys/private +15 -0
 - data/spec/keys/public +6 -0
 - data/spec/models/asymmetric_credential.rb +13 -0
 - data/spec/models/credential.rb +9 -0
 - data/spec/models/sha_credential.rb +11 -0
 - data/spec/models/sha_with_salt_credential.rb +11 -0
 - data/spec/models/symmetric_credential.rb +11 -0
 - data/spec/sha_encryption_spec.rb +57 -0
 - data/spec/sha_with_salt_encryption_spec.rb +27 -0
 - data/spec/spec_helper.rb +20 -0
 - data/spec/symmetric_encryption_spec.rb +23 -0
 - metadata +151 -0
 
    
        data/CHANGELOG.md
    ADDED
    
    
    
        data/LICENSE
    ADDED
    
    | 
         @@ -0,0 +1,20 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            Copyright (c) 2011 Junya Ogura
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            Permission is hereby granted, free of charge, to any person obtaining
         
     | 
| 
      
 4 
     | 
    
         
            +
            a copy of this software and associated documentation files (the
         
     | 
| 
      
 5 
     | 
    
         
            +
            "Software"), to deal in the Software without restriction, including
         
     | 
| 
      
 6 
     | 
    
         
            +
            without limitation the rights to use, copy, modify, merge, publish,
         
     | 
| 
      
 7 
     | 
    
         
            +
            distribute, sublicense, and/or sell copies of the Software, and to
         
     | 
| 
      
 8 
     | 
    
         
            +
            permit persons to whom the Software is furnished to do so, subject to
         
     | 
| 
      
 9 
     | 
    
         
            +
            the following conditions:
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            The above copyright notice and this permission notice shall be
         
     | 
| 
      
 12 
     | 
    
         
            +
            included in all copies or substantial portions of the Software.
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         
     | 
| 
      
 15 
     | 
    
         
            +
            EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         
     | 
| 
      
 16 
     | 
    
         
            +
            MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         
     | 
| 
      
 17 
     | 
    
         
            +
            NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
         
     | 
| 
      
 18 
     | 
    
         
            +
            LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
         
     | 
| 
      
 19 
     | 
    
         
            +
            OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         
     | 
| 
      
 20 
     | 
    
         
            +
            WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         
     | 
    
        data/README.md
    ADDED
    
    | 
         @@ -0,0 +1,145 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            mongoid-encryptor
         
     | 
| 
      
 2 
     | 
    
         
            +
            =================
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            mongoid-encryptor encrypts and decrypts one or more fields in a Mongoid model.
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            Install
         
     | 
| 
      
 8 
     | 
    
         
            +
            -------
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            Put this line in your Gemfile:
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                gem 'mongoid-encryptor'
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            Then bundle:
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                $ bundle
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            Quick Start
         
     | 
| 
      
 20 
     | 
    
         
            +
            -----------
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
            Add mongoid-encryptor to your Gemfile.
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                gem 'mongoid-encryptor', :require => 'mongoid/encryptor'
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
            Set up SHA encrypted field in models like this:
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                class Credential
         
     | 
| 
      
 29 
     | 
    
         
            +
                  include Mongoid::Document
         
     | 
| 
      
 30 
     | 
    
         
            +
                  include Mongoid::Encryptor
         
     | 
| 
      
 31 
     | 
    
         
            +
                  field :password
         
     | 
| 
      
 32 
     | 
    
         
            +
                  encrypts :password
         
     | 
| 
      
 33 
     | 
    
         
            +
                end
         
     | 
| 
      
 34 
     | 
    
         
            +
                
         
     | 
| 
      
 35 
     | 
    
         
            +
                >> c = Credential.new
         
     | 
| 
      
 36 
     | 
    
         
            +
                => #<Credential _id: 4d6383aeb2de3cbea1000001, password: nil>
         
     | 
| 
      
 37 
     | 
    
         
            +
                >> c.password = 'this is a secret'
         
     | 
| 
      
 38 
     | 
    
         
            +
                => "this is a secret"
         
     | 
| 
      
 39 
     | 
    
         
            +
                >> c.password.encrypted?
         
     | 
| 
      
 40 
     | 
    
         
            +
                => false
         
     | 
| 
      
 41 
     | 
    
         
            +
                >> c.save
         
     | 
| 
      
 42 
     | 
    
         
            +
                => true
         
     | 
| 
      
 43 
     | 
    
         
            +
                
         
     | 
| 
      
 44 
     | 
    
         
            +
                >> c.password
         
     | 
| 
      
 45 
     | 
    
         
            +
                => "70a202166f0a78defe464d810f30b50b767cb89a"
         
     | 
| 
      
 46 
     | 
    
         
            +
                >> c.password.encrypted?
         
     | 
| 
      
 47 
     | 
    
         
            +
                => true
         
     | 
| 
      
 48 
     | 
    
         
            +
                >> c.password.cipher.salt
         
     | 
| 
      
 49 
     | 
    
         
            +
                => "salt"
         
     | 
| 
      
 50 
     | 
    
         
            +
                >> c.password == 'this is a secret'
         
     | 
| 
      
 51 
     | 
    
         
            +
                => true
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
            Symmetric encryption
         
     | 
| 
      
 55 
     | 
    
         
            +
            --------------------
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
            Set up Symmetric encrypted field in models like this:
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
                class Credential
         
     | 
| 
      
 60 
     | 
    
         
            +
                  include Mongoid::Document
         
     | 
| 
      
 61 
     | 
    
         
            +
                  include Mongoid::Encryptor
         
     | 
| 
      
 62 
     | 
    
         
            +
                  field :password
         
     | 
| 
      
 63 
     | 
    
         
            +
                  encrypts :password, :mode => :symmetric, :password => 'key'
         
     | 
| 
      
 64 
     | 
    
         
            +
                end
         
     | 
| 
      
 65 
     | 
    
         
            +
                
         
     | 
| 
      
 66 
     | 
    
         
            +
                >> c = Credential.new
         
     | 
| 
      
 67 
     | 
    
         
            +
                => #<Credential _id: 4d638b6db2de3cc2ca000001, password: nil>
         
     | 
| 
      
 68 
     | 
    
         
            +
                >> c.password = 'this is a secret'
         
     | 
| 
      
 69 
     | 
    
         
            +
                => "this is a secret"
         
     | 
| 
      
 70 
     | 
    
         
            +
                >> c.password.encrypted?
         
     | 
| 
      
 71 
     | 
    
         
            +
                => false
         
     | 
| 
      
 72 
     | 
    
         
            +
                >> c.save
         
     | 
| 
      
 73 
     | 
    
         
            +
                => true
         
     | 
| 
      
 74 
     | 
    
         
            +
                
         
     | 
| 
      
 75 
     | 
    
         
            +
                >> c.password
         
     | 
| 
      
 76 
     | 
    
         
            +
                => "y3HnNrU0HviAl3aw2sWH1KttBLsCLYP1\n"
         
     | 
| 
      
 77 
     | 
    
         
            +
                >> c.password.encrypted?
         
     | 
| 
      
 78 
     | 
    
         
            +
                => true
         
     | 
| 
      
 79 
     | 
    
         
            +
                >> c.password.cipher
         
     | 
| 
      
 80 
     | 
    
         
            +
                => #<EncryptedStrings::SymmetricCipher:0x000001016b1c08 @algorithm="DES-EDE3-CBC", @password="key">
         
     | 
| 
      
 81 
     | 
    
         
            +
                >> c.password.cipher.password
         
     | 
| 
      
 82 
     | 
    
         
            +
                => "key"
         
     | 
| 
      
 83 
     | 
    
         
            +
                >> c.password == 'this is a secret'
         
     | 
| 
      
 84 
     | 
    
         
            +
                => true
         
     | 
| 
      
 85 
     | 
    
         
            +
             
     | 
| 
      
 86 
     | 
    
         
            +
             
     | 
| 
      
 87 
     | 
    
         
            +
            Asymmetric encryption
         
     | 
| 
      
 88 
     | 
    
         
            +
            ---------------------
         
     | 
| 
      
 89 
     | 
    
         
            +
             
     | 
| 
      
 90 
     | 
    
         
            +
            Set up Asymmetric encrypted field in models like this:
         
     | 
| 
      
 91 
     | 
    
         
            +
             
     | 
| 
      
 92 
     | 
    
         
            +
                class Credential
         
     | 
| 
      
 93 
     | 
    
         
            +
                  include Mongoid::Document
         
     | 
| 
      
 94 
     | 
    
         
            +
                  include Mongoid::Encryptor
         
     | 
| 
      
 95 
     | 
    
         
            +
                  field :password
         
     | 
| 
      
 96 
     | 
    
         
            +
                  encrypts :password, :mode => :asymmetric,
         
     | 
| 
      
 97 
     | 
    
         
            +
                    :private_key_file => '/path/to/private_key',
         
     | 
| 
      
 98 
     | 
    
         
            +
                    :public_key_file => '/path/to/public_key'
         
     | 
| 
      
 99 
     | 
    
         
            +
                end
         
     | 
| 
      
 100 
     | 
    
         
            +
                
         
     | 
| 
      
 101 
     | 
    
         
            +
                >> c = Credential.new
         
     | 
| 
      
 102 
     | 
    
         
            +
                => #<Credential _id: 4d638ceab2de3cc3c1000001, password: nil>
         
     | 
| 
      
 103 
     | 
    
         
            +
                >> c.password = 'this is a secret'
         
     | 
| 
      
 104 
     | 
    
         
            +
                => "this is a secret"
         
     | 
| 
      
 105 
     | 
    
         
            +
                >> c.password.encrypted?
         
     | 
| 
      
 106 
     | 
    
         
            +
                => false
         
     | 
| 
      
 107 
     | 
    
         
            +
                >> c.save
         
     | 
| 
      
 108 
     | 
    
         
            +
                => true
         
     | 
| 
      
 109 
     | 
    
         
            +
                
         
     | 
| 
      
 110 
     | 
    
         
            +
                >> c.password
         
     | 
| 
      
 111 
     | 
    
         
            +
                => "ha/2EacZTmvAIHOSjFEshM+9UHUItB/wGKJ5ftClQDllA9SOBJJazTlsMS9m\nPd5W3goZbY9V2dDdNo4NgQ0e8VsG0dpcvOIrua/ye+jX3e+0ocevcnOH9PL9\n8C5P8caOD/sKlKLTI0Dr1v/6d/f0Q4UuPQyTh3d4aEWyagypWyQ=\n"
         
     | 
| 
      
 112 
     | 
    
         
            +
                >> c.password.encrypted?
         
     | 
| 
      
 113 
     | 
    
         
            +
                => true
         
     | 
| 
      
 114 
     | 
    
         
            +
                >> c.password == 'this is a secret'
         
     | 
| 
      
 115 
     | 
    
         
            +
                => true
         
     | 
| 
      
 116 
     | 
    
         
            +
             
     | 
| 
      
 117 
     | 
    
         
            +
            You can generate keypair like this:
         
     | 
| 
      
 118 
     | 
    
         
            +
             
     | 
| 
      
 119 
     | 
    
         
            +
                $ openssl genrsa -des3 -out private 1024  # generate private key
         
     | 
| 
      
 120 
     | 
    
         
            +
                $ openssl rsa -in private -pubout -out public  # generate public key
         
     | 
| 
      
 121 
     | 
    
         
            +
                $ mv private private.bak
         
     | 
| 
      
 122 
     | 
    
         
            +
                $ openssl rsa -in private.bak -out private  # remove passphrase from private key
         
     | 
| 
      
 123 
     | 
    
         
            +
                $ ls -l
         
     | 
| 
      
 124 
     | 
    
         
            +
                -rw-r--r--   1 juno  staff   887  2 22 19:20 private
         
     | 
| 
      
 125 
     | 
    
         
            +
                -rw-r--r--   1 juno  staff   963  2 22 19:19 private.bak
         
     | 
| 
      
 126 
     | 
    
         
            +
                -rw-r--r--   1 juno  staff   272  2 22 19:19 public
         
     | 
| 
      
 127 
     | 
    
         
            +
             
     | 
| 
      
 128 
     | 
    
         
            +
             
     | 
| 
      
 129 
     | 
    
         
            +
            Questions, Feedback
         
     | 
| 
      
 130 
     | 
    
         
            +
            -------------------
         
     | 
| 
      
 131 
     | 
    
         
            +
             
     | 
| 
      
 132 
     | 
    
         
            +
            [github/juno](http://github.com/juno/) or [@junya](http://twitter.com/junya).
         
     | 
| 
      
 133 
     | 
    
         
            +
             
     | 
| 
      
 134 
     | 
    
         
            +
             
     | 
| 
      
 135 
     | 
    
         
            +
            References
         
     | 
| 
      
 136 
     | 
    
         
            +
            ----------
         
     | 
| 
      
 137 
     | 
    
         
            +
             
     | 
| 
      
 138 
     | 
    
         
            +
            *  [pluginaweek/encrypted_strings](https://github.com/pluginaweek/encrypted_strings)
         
     | 
| 
      
 139 
     | 
    
         
            +
            *  [pluginaweek/encrypted_attributes](https://github.com/pluginaweek/encrypted_attributes)
         
     | 
| 
      
 140 
     | 
    
         
            +
             
     | 
| 
      
 141 
     | 
    
         
            +
             
     | 
| 
      
 142 
     | 
    
         
            +
            Copyright
         
     | 
| 
      
 143 
     | 
    
         
            +
            ---------
         
     | 
| 
      
 144 
     | 
    
         
            +
             
     | 
| 
      
 145 
     | 
    
         
            +
            (c) 2011 Junya Ogura. See LICENSE.txt for further details.
         
     | 
| 
         @@ -0,0 +1,72 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # -*- encoding: utf-8 -*-
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'encrypted_strings'
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            module Mongoid #:nodoc:
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
              # mongoid-encryptor encrypts and decrypts one or more fields in a Mongoid model.
         
     | 
| 
      
 7 
     | 
    
         
            +
              module Encryptor
         
     | 
| 
      
 8 
     | 
    
         
            +
                extend ActiveSupport::Concern
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                module ClassMethods #:nodoc:
         
     | 
| 
      
 11 
     | 
    
         
            +
                  # @param [Hash] attrs
         
     | 
| 
      
 12 
     | 
    
         
            +
                  def encrypts(*attrs)
         
     | 
| 
      
 13 
     | 
    
         
            +
                    base_options = attrs.last.is_a?(Hash) ? attrs.pop : {}
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                    attrs.each do |attr_name|
         
     | 
| 
      
 16 
     | 
    
         
            +
                      options = base_options.dup
         
     | 
| 
      
 17 
     | 
    
         
            +
                      attr_name = attr_name.to_s
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                      mode = options.delete(:mode) || :sha
         
     | 
| 
      
 20 
     | 
    
         
            +
                      cipher_class = EncryptedStrings.const_get("#{mode.to_s.classify}Cipher")
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                      send(:before_validation) do |doc|
         
     | 
| 
      
 23 
     | 
    
         
            +
                        doc.send(:write_encrypted_attribute, attr_name, cipher_class, options)
         
     | 
| 
      
 24 
     | 
    
         
            +
                        true
         
     | 
| 
      
 25 
     | 
    
         
            +
                      end
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
                      define_method(attr_name) do
         
     | 
| 
      
 28 
     | 
    
         
            +
                        read_encrypted_attribute(attr_name, cipher_class, options)
         
     | 
| 
      
 29 
     | 
    
         
            +
                      end
         
     | 
| 
      
 30 
     | 
    
         
            +
                    end
         
     | 
| 
      
 31 
     | 
    
         
            +
                  end
         
     | 
| 
      
 32 
     | 
    
         
            +
                end
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                module InstanceMethods #:nodoc:
         
     | 
| 
      
 35 
     | 
    
         
            +
                  private
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                  # @param [String] attr_name
         
     | 
| 
      
 38 
     | 
    
         
            +
                  # @param [Class] cipher_class
         
     | 
| 
      
 39 
     | 
    
         
            +
                  # @param [Hash] options
         
     | 
| 
      
 40 
     | 
    
         
            +
                  def write_encrypted_attribute(attr_name, cipher_class, options)
         
     | 
| 
      
 41 
     | 
    
         
            +
                    value = read_attribute(attr_name.to_sym)
         
     | 
| 
      
 42 
     | 
    
         
            +
                    return if value.blank? or value.encrypted?
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
                    cipher = instantiate_cipher(cipher_class, options)
         
     | 
| 
      
 45 
     | 
    
         
            +
                    value = cipher.encrypt(value)
         
     | 
| 
      
 46 
     | 
    
         
            +
                    value.cipher = cipher
         
     | 
| 
      
 47 
     | 
    
         
            +
                    send("#{attr_name}=", value)
         
     | 
| 
      
 48 
     | 
    
         
            +
                  end
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
                  # @param [String] attr_name
         
     | 
| 
      
 51 
     | 
    
         
            +
                  # @param [Class] cipher_class
         
     | 
| 
      
 52 
     | 
    
         
            +
                  # @param [Hash] options
         
     | 
| 
      
 53 
     | 
    
         
            +
                  def read_encrypted_attribute(attr_name, cipher_class, options)
         
     | 
| 
      
 54 
     | 
    
         
            +
                    value = read_attribute(attr_name)
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
                    unless value.blank? || value.encrypted? || attribute_changed?(attr_name) || new_record?
         
     | 
| 
      
 57 
     | 
    
         
            +
                      value.cipher = instantiate_cipher(cipher_class, options)
         
     | 
| 
      
 58 
     | 
    
         
            +
                    end
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
                    value
         
     | 
| 
      
 61 
     | 
    
         
            +
                  end
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
                  # @param [Class] cipher_class
         
     | 
| 
      
 64 
     | 
    
         
            +
                  # @param [Hash] options
         
     | 
| 
      
 65 
     | 
    
         
            +
                  # @return [EncryptedStrings::Cipher]
         
     | 
| 
      
 66 
     | 
    
         
            +
                  def instantiate_cipher(cipher_class, options)
         
     | 
| 
      
 67 
     | 
    
         
            +
                    cipher_class.new(options.dup)
         
     | 
| 
      
 68 
     | 
    
         
            +
                  end
         
     | 
| 
      
 69 
     | 
    
         
            +
                end
         
     | 
| 
      
 70 
     | 
    
         
            +
              end
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,27 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # -*- encoding: utf-8 -*-
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'spec_helper'
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            describe 'Asymmetric encryption' do
         
     | 
| 
      
 5 
     | 
    
         
            +
              let(:credential) { AsymmetricCredential.create(:email => 'john.smith@example.com', :password => 'this is a secret') }
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
              context "#to_s" do
         
     | 
| 
      
 8 
     | 
    
         
            +
                subject { "#{credential.password}" }
         
     | 
| 
      
 9 
     | 
    
         
            +
                it { should_not eq('this is a secret') }
         
     | 
| 
      
 10 
     | 
    
         
            +
              end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
              context "'this is a secret'" do
         
     | 
| 
      
 13 
     | 
    
         
            +
                subject { credential.password }
         
     | 
| 
      
 14 
     | 
    
         
            +
                it { should be_encrypted }
         
     | 
| 
      
 15 
     | 
    
         
            +
                it { should eq('this is a secret') }
         
     | 
| 
      
 16 
     | 
    
         
            +
              end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
              context "attribute length" do
         
     | 
| 
      
 19 
     | 
    
         
            +
                subject { credential.password.length }
         
     | 
| 
      
 20 
     | 
    
         
            +
                it { should eq(175) }
         
     | 
| 
      
 21 
     | 
    
         
            +
              end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
              context "cipher" do
         
     | 
| 
      
 24 
     | 
    
         
            +
                subject { credential.password.cipher }
         
     | 
| 
      
 25 
     | 
    
         
            +
                it { should be_an_instance_of(EncryptedStrings::AsymmetricCipher) }
         
     | 
| 
      
 26 
     | 
    
         
            +
              end
         
     | 
| 
      
 27 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,11 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # -*- encoding: utf-8 -*-
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'spec_helper'
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            describe 'Encrypted attributes' do
         
     | 
| 
      
 5 
     | 
    
         
            +
              context "Not encryption" do
         
     | 
| 
      
 6 
     | 
    
         
            +
                let(:credential) { Credential.create(:email => 'john.smith@example.com') }
         
     | 
| 
      
 7 
     | 
    
         
            +
                before { credential.password = 'this is not a secret' }
         
     | 
| 
      
 8 
     | 
    
         
            +
                subject { credential.password }
         
     | 
| 
      
 9 
     | 
    
         
            +
                it { should eq('this is not a secret') }
         
     | 
| 
      
 10 
     | 
    
         
            +
              end
         
     | 
| 
      
 11 
     | 
    
         
            +
            end
         
     | 
    
        data/spec/keys/private
    ADDED
    
    | 
         @@ -0,0 +1,15 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            -----BEGIN RSA PRIVATE KEY-----
         
     | 
| 
      
 2 
     | 
    
         
            +
            MIICXQIBAAKBgQDYVF73yp10OGVKO0UYrVwFO4bKJv4i4V1Et7KeHfdCFVU7/oxA
         
     | 
| 
      
 3 
     | 
    
         
            +
            tISjKvlh/KdBE+dlqCAgxemThANkAspQRr6BSe5jqgDHea2Qd6qvq4JgkxCLr3Io
         
     | 
| 
      
 4 
     | 
    
         
            +
            irxQ79zKw2rvhPsWMAyFNdRHlGBCyIP/If0htPccX0HbGk0lVBGN9cFWLwIDAQAB
         
     | 
| 
      
 5 
     | 
    
         
            +
            AoGBAJtpcZh+vUNDSLFdhzRFRviTXTBZdvXEBedaOT4StRGKleM16biKd0dpliNp
         
     | 
| 
      
 6 
     | 
    
         
            +
            CRddnz2O3RXuWPGbQ3xT7NhjGnQhYsSKbPXQRpp+BdaiR/B36R9L/DYVxquOqpeQ
         
     | 
| 
      
 7 
     | 
    
         
            +
            fR2Q2tRXANAw8fPvI3rANq1oNZFKTma8dP2D+cyf7/YTrndBAkEA77+DIjE+Iy5c
         
     | 
| 
      
 8 
     | 
    
         
            +
            BNEiOYCLkSEo239vl0Qy1EwVovdzDiPnhjEj6q1weVtMOplJ1uoACUTikMuny2EO
         
     | 
| 
      
 9 
     | 
    
         
            +
            s773h4yunwJBAOb+dquUgfKAlO+aGGwybUDeb9Etgqo2p+dmFqqcGknAi6+lmTOQ
         
     | 
| 
      
 10 
     | 
    
         
            +
            V120tXXdf184W7AGpp/X9rARs1TRF5+KfnECQQDYbGCbSCqYpavpqUSk9faHn5B7
         
     | 
| 
      
 11 
     | 
    
         
            +
            fPGmcqkT3k8V2x0g4aaKC+gpXEIROyp4J5JxkLFRrL5+CWpCfS5Bcp2O3p9vAkBI
         
     | 
| 
      
 12 
     | 
    
         
            +
            Hv8SR0XjXz4hKS2i6oOuE0U6PEllt7boyrkc/6w9hr6WUs/oh5KfkUJu0H9qTYBj
         
     | 
| 
      
 13 
     | 
    
         
            +
            D1CK67T7+CrTuozzpRwhAkB80NeUiQNpQqlCRmeoo+XjHXFsoIRZO9sMs86nBkJ+
         
     | 
| 
      
 14 
     | 
    
         
            +
            p4HVUKhDgMSTGA8V0P/h9zDFo8iPtarcAA/WlEm6mLwV
         
     | 
| 
      
 15 
     | 
    
         
            +
            -----END RSA PRIVATE KEY-----
         
     | 
    
        data/spec/keys/public
    ADDED
    
    | 
         @@ -0,0 +1,6 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            -----BEGIN PUBLIC KEY-----
         
     | 
| 
      
 2 
     | 
    
         
            +
            MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDYVF73yp10OGVKO0UYrVwFO4bK
         
     | 
| 
      
 3 
     | 
    
         
            +
            Jv4i4V1Et7KeHfdCFVU7/oxAtISjKvlh/KdBE+dlqCAgxemThANkAspQRr6BSe5j
         
     | 
| 
      
 4 
     | 
    
         
            +
            qgDHea2Qd6qvq4JgkxCLr3IoirxQ79zKw2rvhPsWMAyFNdRHlGBCyIP/If0htPcc
         
     | 
| 
      
 5 
     | 
    
         
            +
            X0HbGk0lVBGN9cFWLwIDAQAB
         
     | 
| 
      
 6 
     | 
    
         
            +
            -----END PUBLIC KEY-----
         
     | 
| 
         @@ -0,0 +1,13 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            class AsymmetricCredential
         
     | 
| 
      
 2 
     | 
    
         
            +
              include Mongoid::Document
         
     | 
| 
      
 3 
     | 
    
         
            +
              include Mongoid::Encryptor
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
              field :email
         
     | 
| 
      
 6 
     | 
    
         
            +
              field :password
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
              validates_presence_of :email, :password
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
              encrypts :password, :mode => :asymmetric,
         
     | 
| 
      
 11 
     | 
    
         
            +
                :private_key_file => File.dirname(__FILE__) + '/../keys/private',
         
     | 
| 
      
 12 
     | 
    
         
            +
                :public_key_file => File.dirname(__FILE__) + '/../keys/public'
         
     | 
| 
      
 13 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,57 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # -*- encoding: utf-8 -*-
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'spec_helper'
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            describe 'SHA encryption' do
         
     | 
| 
      
 5 
     | 
    
         
            +
              let(:credential) { ShaCredential.create(:email => 'john.smith@example.com', :password => 'this is a secret') }
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
              context "#to_s" do
         
     | 
| 
      
 8 
     | 
    
         
            +
                subject { "#{credential.password}" }
         
     | 
| 
      
 9 
     | 
    
         
            +
                it { should eq("70a202166f0a78defe464d810f30b50b767cb89a") }
         
     | 
| 
      
 10 
     | 
    
         
            +
              end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
              context "'this is a secret'" do
         
     | 
| 
      
 13 
     | 
    
         
            +
                subject { credential.password }
         
     | 
| 
      
 14 
     | 
    
         
            +
                it { should be_encrypted }
         
     | 
| 
      
 15 
     | 
    
         
            +
                it { should eq('this is a secret') }
         
     | 
| 
      
 16 
     | 
    
         
            +
              end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
              context "cipher" do
         
     | 
| 
      
 19 
     | 
    
         
            +
                subject { credential.password.cipher }
         
     | 
| 
      
 20 
     | 
    
         
            +
                it { should be_an_instance_of(EncryptedStrings::ShaCipher) }
         
     | 
| 
      
 21 
     | 
    
         
            +
              end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
              context "use default salt" do
         
     | 
| 
      
 24 
     | 
    
         
            +
                subject { credential.password.cipher.salt }
         
     | 
| 
      
 25 
     | 
    
         
            +
                it { should eq('salt') }
         
     | 
| 
      
 26 
     | 
    
         
            +
              end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
              context "load from database" do
         
     | 
| 
      
 29 
     | 
    
         
            +
                subject { ShaCredential.find(credential.id).password }
         
     | 
| 
      
 30 
     | 
    
         
            +
                it { should be_encrypted }
         
     | 
| 
      
 31 
     | 
    
         
            +
                it { should eq('this is a secret') }
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                context "#to_s" do
         
     | 
| 
      
 34 
     | 
    
         
            +
                  subject { "#{ShaCredential.find(credential.id).password}" }
         
     | 
| 
      
 35 
     | 
    
         
            +
                  it { should eq("70a202166f0a78defe464d810f30b50b767cb89a") }
         
     | 
| 
      
 36 
     | 
    
         
            +
                end
         
     | 
| 
      
 37 
     | 
    
         
            +
              end
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
              context "with mass assignment" do
         
     | 
| 
      
 40 
     | 
    
         
            +
                let(:credential) { ShaCredential.new(:email => 'john.smith@example.com', :password => 'this is a secret') }
         
     | 
| 
      
 41 
     | 
    
         
            +
                subject { credential.password }
         
     | 
| 
      
 42 
     | 
    
         
            +
                it { should eq('this is a secret') }
         
     | 
| 
      
 43 
     | 
    
         
            +
                it { should_not be_encrypted }
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
                context "after save" do
         
     | 
| 
      
 46 
     | 
    
         
            +
                  before { credential.save! }
         
     | 
| 
      
 47 
     | 
    
         
            +
                  subject { credential.password }
         
     | 
| 
      
 48 
     | 
    
         
            +
                  it { should be_encrypted }
         
     | 
| 
      
 49 
     | 
    
         
            +
                  it { should eq('this is a secret') }
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
                  context "#to_s" do
         
     | 
| 
      
 52 
     | 
    
         
            +
                    subject { "#{credential.password}" }
         
     | 
| 
      
 53 
     | 
    
         
            +
                    it { should eq('70a202166f0a78defe464d810f30b50b767cb89a') }
         
     | 
| 
      
 54 
     | 
    
         
            +
                  end
         
     | 
| 
      
 55 
     | 
    
         
            +
                end
         
     | 
| 
      
 56 
     | 
    
         
            +
              end
         
     | 
| 
      
 57 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,27 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # -*- encoding: utf-8 -*-
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'spec_helper'
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            describe 'SHA with salt encryption' do
         
     | 
| 
      
 5 
     | 
    
         
            +
              let(:credential) { ShaWithSaltCredential.create(:email => 'john.smith@example.com', :password => 'this is a secret') }
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
              context "#to_s" do
         
     | 
| 
      
 8 
     | 
    
         
            +
                subject { "#{credential.password}" }
         
     | 
| 
      
 9 
     | 
    
         
            +
                it { should eq("f218935d0c4b9a5e6d5faae7bc6b6bd35f319cbe") }
         
     | 
| 
      
 10 
     | 
    
         
            +
              end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
              context "'this is a secret'" do
         
     | 
| 
      
 13 
     | 
    
         
            +
                subject { credential.password }
         
     | 
| 
      
 14 
     | 
    
         
            +
                it { should be_encrypted }
         
     | 
| 
      
 15 
     | 
    
         
            +
                it { should eq('this is a secret') }
         
     | 
| 
      
 16 
     | 
    
         
            +
              end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
              context "cipher" do
         
     | 
| 
      
 19 
     | 
    
         
            +
                subject { credential.password.cipher }
         
     | 
| 
      
 20 
     | 
    
         
            +
                it { should be_an_instance_of(EncryptedStrings::ShaCipher) }
         
     | 
| 
      
 21 
     | 
    
         
            +
              end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
              context "use custom salt" do
         
     | 
| 
      
 24 
     | 
    
         
            +
                subject { credential.password.cipher.salt }
         
     | 
| 
      
 25 
     | 
    
         
            +
                it { should eq('admin') }
         
     | 
| 
      
 26 
     | 
    
         
            +
              end
         
     | 
| 
      
 27 
     | 
    
         
            +
            end
         
     | 
    
        data/spec/spec_helper.rb
    ADDED
    
    | 
         @@ -0,0 +1,20 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'rubygems'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'bundler/setup'
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            require 'database_cleaner'
         
     | 
| 
      
 5 
     | 
    
         
            +
            require 'mongoid'
         
     | 
| 
      
 6 
     | 
    
         
            +
            require 'rspec'
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            Mongoid.configure do |config|
         
     | 
| 
      
 9 
     | 
    
         
            +
              name = 'mongoid_encryptor_test'
         
     | 
| 
      
 10 
     | 
    
         
            +
              config.master = Mongo::Connection.new.db(name)
         
     | 
| 
      
 11 
     | 
    
         
            +
            end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            require File.expand_path("../../lib/mongoid/encryptor", __FILE__)
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            Dir["#{File.dirname(__FILE__)}/models/*.rb"].each {|f| require f}
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            RSpec.configure do |config|
         
     | 
| 
      
 18 
     | 
    
         
            +
              config.before(:all) { DatabaseCleaner.strategy = :truncation }
         
     | 
| 
      
 19 
     | 
    
         
            +
              config.before(:each) { DatabaseCleaner.clean }
         
     | 
| 
      
 20 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,23 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # -*- encoding: utf-8 -*-
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'spec_helper'
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            describe "Symmetric encryption" do
         
     | 
| 
      
 5 
     | 
    
         
            +
              let(:credential) { SymmetricCredential.create(:email => 'john.smith@example.com', :password => 'this is a secret') }
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
              context "'this is a secret'" do
         
     | 
| 
      
 8 
     | 
    
         
            +
                subject { credential.password }
         
     | 
| 
      
 9 
     | 
    
         
            +
                it { should eq("y3HnNrU0HviAl3aw2sWH1KttBLsCLYP1\n") }
         
     | 
| 
      
 10 
     | 
    
         
            +
                it { should be_encrypted }
         
     | 
| 
      
 11 
     | 
    
         
            +
                it { should eq('this is a secret') }
         
     | 
| 
      
 12 
     | 
    
         
            +
              end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
              context 'cipher' do
         
     | 
| 
      
 15 
     | 
    
         
            +
                subject { credential.password.cipher }
         
     | 
| 
      
 16 
     | 
    
         
            +
                it { should be_an_instance_of(EncryptedStrings::SymmetricCipher) }
         
     | 
| 
      
 17 
     | 
    
         
            +
              end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
              context 'cipher password' do
         
     | 
| 
      
 20 
     | 
    
         
            +
                subject { credential.password.cipher.password }
         
     | 
| 
      
 21 
     | 
    
         
            +
                it { should eq('key') }
         
     | 
| 
      
 22 
     | 
    
         
            +
              end
         
     | 
| 
      
 23 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,151 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification 
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: mongoid-encryptor
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version 
         
     | 
| 
      
 4 
     | 
    
         
            +
              prerelease: 
         
     | 
| 
      
 5 
     | 
    
         
            +
              version: 0.0.1
         
     | 
| 
      
 6 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 7 
     | 
    
         
            +
            authors: 
         
     | 
| 
      
 8 
     | 
    
         
            +
            - Junya Ogura
         
     | 
| 
      
 9 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 10 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 11 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            date: 2011-02-22 00:00:00 +09:00
         
     | 
| 
      
 14 
     | 
    
         
            +
            default_executable: 
         
     | 
| 
      
 15 
     | 
    
         
            +
            dependencies: 
         
     | 
| 
      
 16 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency 
         
     | 
| 
      
 17 
     | 
    
         
            +
              name: mongoid
         
     | 
| 
      
 18 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 19 
     | 
    
         
            +
              requirement: &id001 !ruby/object:Gem::Requirement 
         
     | 
| 
      
 20 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 21 
     | 
    
         
            +
                requirements: 
         
     | 
| 
      
 22 
     | 
    
         
            +
                - - ~>
         
     | 
| 
      
 23 
     | 
    
         
            +
                  - !ruby/object:Gem::Version 
         
     | 
| 
      
 24 
     | 
    
         
            +
                    version: 2.0.0.rc.7
         
     | 
| 
      
 25 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 26 
     | 
    
         
            +
              version_requirements: *id001
         
     | 
| 
      
 27 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency 
         
     | 
| 
      
 28 
     | 
    
         
            +
              name: encrypted_strings
         
     | 
| 
      
 29 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 30 
     | 
    
         
            +
              requirement: &id002 !ruby/object:Gem::Requirement 
         
     | 
| 
      
 31 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 32 
     | 
    
         
            +
                requirements: 
         
     | 
| 
      
 33 
     | 
    
         
            +
                - - ~>
         
     | 
| 
      
 34 
     | 
    
         
            +
                  - !ruby/object:Gem::Version 
         
     | 
| 
      
 35 
     | 
    
         
            +
                    version: 0.3.3
         
     | 
| 
      
 36 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 37 
     | 
    
         
            +
              version_requirements: *id002
         
     | 
| 
      
 38 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency 
         
     | 
| 
      
 39 
     | 
    
         
            +
              name: bson_ext
         
     | 
| 
      
 40 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 41 
     | 
    
         
            +
              requirement: &id003 !ruby/object:Gem::Requirement 
         
     | 
| 
      
 42 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 43 
     | 
    
         
            +
                requirements: 
         
     | 
| 
      
 44 
     | 
    
         
            +
                - - ~>
         
     | 
| 
      
 45 
     | 
    
         
            +
                  - !ruby/object:Gem::Version 
         
     | 
| 
      
 46 
     | 
    
         
            +
                    version: 1.2.0
         
     | 
| 
      
 47 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 48 
     | 
    
         
            +
              version_requirements: *id003
         
     | 
| 
      
 49 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency 
         
     | 
| 
      
 50 
     | 
    
         
            +
              name: database_cleaner
         
     | 
| 
      
 51 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 52 
     | 
    
         
            +
              requirement: &id004 !ruby/object:Gem::Requirement 
         
     | 
| 
      
 53 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 54 
     | 
    
         
            +
                requirements: 
         
     | 
| 
      
 55 
     | 
    
         
            +
                - - ~>
         
     | 
| 
      
 56 
     | 
    
         
            +
                  - !ruby/object:Gem::Version 
         
     | 
| 
      
 57 
     | 
    
         
            +
                    version: 0.6.0
         
     | 
| 
      
 58 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 59 
     | 
    
         
            +
              version_requirements: *id004
         
     | 
| 
      
 60 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency 
         
     | 
| 
      
 61 
     | 
    
         
            +
              name: rspec
         
     | 
| 
      
 62 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 63 
     | 
    
         
            +
              requirement: &id005 !ruby/object:Gem::Requirement 
         
     | 
| 
      
 64 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 65 
     | 
    
         
            +
                requirements: 
         
     | 
| 
      
 66 
     | 
    
         
            +
                - - ~>
         
     | 
| 
      
 67 
     | 
    
         
            +
                  - !ruby/object:Gem::Version 
         
     | 
| 
      
 68 
     | 
    
         
            +
                    version: 2.4.0
         
     | 
| 
      
 69 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 70 
     | 
    
         
            +
              version_requirements: *id005
         
     | 
| 
      
 71 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency 
         
     | 
| 
      
 72 
     | 
    
         
            +
              name: ruby-debug19
         
     | 
| 
      
 73 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 74 
     | 
    
         
            +
              requirement: &id006 !ruby/object:Gem::Requirement 
         
     | 
| 
      
 75 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 76 
     | 
    
         
            +
                requirements: 
         
     | 
| 
      
 77 
     | 
    
         
            +
                - - ~>
         
     | 
| 
      
 78 
     | 
    
         
            +
                  - !ruby/object:Gem::Version 
         
     | 
| 
      
 79 
     | 
    
         
            +
                    version: 0.11.0
         
     | 
| 
      
 80 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 81 
     | 
    
         
            +
              version_requirements: *id006
         
     | 
| 
      
 82 
     | 
    
         
            +
            description: mongoid-encryptor encrypts and decrypts one or more fields in a Mongoid model.
         
     | 
| 
      
 83 
     | 
    
         
            +
            email: 
         
     | 
| 
      
 84 
     | 
    
         
            +
            - junyaogura@gmail.com
         
     | 
| 
      
 85 
     | 
    
         
            +
            executables: []
         
     | 
| 
      
 86 
     | 
    
         
            +
             
     | 
| 
      
 87 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 88 
     | 
    
         
            +
             
     | 
| 
      
 89 
     | 
    
         
            +
            extra_rdoc_files: []
         
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
| 
      
 91 
     | 
    
         
            +
            files: 
         
     | 
| 
      
 92 
     | 
    
         
            +
            - lib/mongoid/encryptor/version.rb
         
     | 
| 
      
 93 
     | 
    
         
            +
            - lib/mongoid/encryptor.rb
         
     | 
| 
      
 94 
     | 
    
         
            +
            - CHANGELOG.md
         
     | 
| 
      
 95 
     | 
    
         
            +
            - LICENSE
         
     | 
| 
      
 96 
     | 
    
         
            +
            - README.md
         
     | 
| 
      
 97 
     | 
    
         
            +
            - spec/asymmetric_encryption_spec.rb
         
     | 
| 
      
 98 
     | 
    
         
            +
            - spec/encrypted_attributes_spec.rb
         
     | 
| 
      
 99 
     | 
    
         
            +
            - spec/keys/private
         
     | 
| 
      
 100 
     | 
    
         
            +
            - spec/keys/public
         
     | 
| 
      
 101 
     | 
    
         
            +
            - spec/models/asymmetric_credential.rb
         
     | 
| 
      
 102 
     | 
    
         
            +
            - spec/models/credential.rb
         
     | 
| 
      
 103 
     | 
    
         
            +
            - spec/models/sha_credential.rb
         
     | 
| 
      
 104 
     | 
    
         
            +
            - spec/models/sha_with_salt_credential.rb
         
     | 
| 
      
 105 
     | 
    
         
            +
            - spec/models/symmetric_credential.rb
         
     | 
| 
      
 106 
     | 
    
         
            +
            - spec/sha_encryption_spec.rb
         
     | 
| 
      
 107 
     | 
    
         
            +
            - spec/sha_with_salt_encryption_spec.rb
         
     | 
| 
      
 108 
     | 
    
         
            +
            - spec/spec_helper.rb
         
     | 
| 
      
 109 
     | 
    
         
            +
            - spec/symmetric_encryption_spec.rb
         
     | 
| 
      
 110 
     | 
    
         
            +
            has_rdoc: true
         
     | 
| 
      
 111 
     | 
    
         
            +
            homepage: http://github.com/juno/mongoid-encryptor
         
     | 
| 
      
 112 
     | 
    
         
            +
            licenses: []
         
     | 
| 
      
 113 
     | 
    
         
            +
             
     | 
| 
      
 114 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
      
 115 
     | 
    
         
            +
            rdoc_options: []
         
     | 
| 
      
 116 
     | 
    
         
            +
             
     | 
| 
      
 117 
     | 
    
         
            +
            require_paths: 
         
     | 
| 
      
 118 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 119 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement 
         
     | 
| 
      
 120 
     | 
    
         
            +
              none: false
         
     | 
| 
      
 121 
     | 
    
         
            +
              requirements: 
         
     | 
| 
      
 122 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 123 
     | 
    
         
            +
                - !ruby/object:Gem::Version 
         
     | 
| 
      
 124 
     | 
    
         
            +
                  version: "0"
         
     | 
| 
      
 125 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement 
         
     | 
| 
      
 126 
     | 
    
         
            +
              none: false
         
     | 
| 
      
 127 
     | 
    
         
            +
              requirements: 
         
     | 
| 
      
 128 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 129 
     | 
    
         
            +
                - !ruby/object:Gem::Version 
         
     | 
| 
      
 130 
     | 
    
         
            +
                  version: "0"
         
     | 
| 
      
 131 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 132 
     | 
    
         
            +
             
     | 
| 
      
 133 
     | 
    
         
            +
            rubyforge_project: mongoid-encryptor
         
     | 
| 
      
 134 
     | 
    
         
            +
            rubygems_version: 1.5.0
         
     | 
| 
      
 135 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 136 
     | 
    
         
            +
            specification_version: 3
         
     | 
| 
      
 137 
     | 
    
         
            +
            summary: Encrypt a Mongoid model fields
         
     | 
| 
      
 138 
     | 
    
         
            +
            test_files: 
         
     | 
| 
      
 139 
     | 
    
         
            +
            - spec/asymmetric_encryption_spec.rb
         
     | 
| 
      
 140 
     | 
    
         
            +
            - spec/encrypted_attributes_spec.rb
         
     | 
| 
      
 141 
     | 
    
         
            +
            - spec/keys/private
         
     | 
| 
      
 142 
     | 
    
         
            +
            - spec/keys/public
         
     | 
| 
      
 143 
     | 
    
         
            +
            - spec/models/asymmetric_credential.rb
         
     | 
| 
      
 144 
     | 
    
         
            +
            - spec/models/credential.rb
         
     | 
| 
      
 145 
     | 
    
         
            +
            - spec/models/sha_credential.rb
         
     | 
| 
      
 146 
     | 
    
         
            +
            - spec/models/sha_with_salt_credential.rb
         
     | 
| 
      
 147 
     | 
    
         
            +
            - spec/models/symmetric_credential.rb
         
     | 
| 
      
 148 
     | 
    
         
            +
            - spec/sha_encryption_spec.rb
         
     | 
| 
      
 149 
     | 
    
         
            +
            - spec/sha_with_salt_encryption_spec.rb
         
     | 
| 
      
 150 
     | 
    
         
            +
            - spec/spec_helper.rb
         
     | 
| 
      
 151 
     | 
    
         
            +
            - spec/symmetric_encryption_spec.rb
         
     |