Sha256: faff41404b7e51ef3635df1f2d672ff4096d8855a69f6e7fdc5fd36171e9d768

Contents?: true

Size: 935 Bytes

Versions: 14

Compression:

Stored size: 935 Bytes

Contents

module CryptKeeper
  module Provider
    # A fake class that does no encryption
    class FakeEncryptor
      def initialize(*args)
      end

      def encrypt(value)
        value
      end

      def decrypt(value)
        value
      end
    end

    class SearchEncryptor
      def initialize(*args)
      end

      def encrypt(value)
        value
      end

      def decrypt(value)
        value
      end

      def search(records, field, criteria)
        records.select { |record| record[field] == criteria }
      end
    end


    # This class embeds the passphrase in the beginning of the string
    # and then reverses the 'plaintext'
    class Encryptor
      def initialize(options = {})
        @passphrase = options[:passphrase]
      end

      def encrypt(data)
        @passphrase + data.reverse
      end

      def decrypt(data)
        data.to_s.sub(/^#{@passphrase}/, '').reverse
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
crypt_keeper-0.22.0 spec/support/encryptors.rb
crypt_keeper-0.21.0 spec/support/encryptors.rb
crypt_keeper-0.20.0 spec/support/encryptors.rb
crypt_keeper-0.19.0 spec/support/encryptors.rb
crypt_keeper-0.18.4 spec/support/encryptors.rb
crypt_keeper-0.18.3 spec/support/encryptors.rb
crypt_keeper-0.18.2 spec/support/encryptors.rb
crypt_keeper-0.18.1 spec/support/encryptors.rb
crypt_keeper-0.18.0 spec/support/encryptors.rb
crypt_keeper-0.17.0 spec/support/encryptors.rb
crypt_keeper-0.16.1 spec/support/encryptors.rb
crypt_keeper-0.16.0 spec/support/encryptors.rb
crypt_keeper-0.16.0.pre spec/support/encryptors.rb
crypt_keeper-0.15.0.pre spec/support/encryptors.rb