Sha256: c44f727297f8a5c9dab3a86fb870db0ccb592c562a1ca7cb93c98321b1467313

Contents?: true

Size: 1.05 KB

Versions: 11

Compression:

Stored size: 1.05 KB

Contents

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

    # A fake class that does no encryption
    class FakeEncryptor < Base
      def initialize(*args)
      end

      def encrypt(value)
        value
      end

      def decrypt(value)
        value
      end
    end

    class SearchEncryptor < Base
      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 < Base
      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

11 entries across 11 versions & 1 rubygems

Version Path
crypt_keeper-2.3.0 spec/support/encryptors.rb
crypt_keeper-2.2.0 spec/support/encryptors.rb
crypt_keeper-2.1.0 spec/support/encryptors.rb
crypt_keeper-2.0.1 spec/support/encryptors.rb
crypt_keeper-2.0.0.rc2 spec/support/encryptors.rb
crypt_keeper-2.0.0.rc1 spec/support/encryptors.rb
crypt_keeper-1.1.1 spec/support/encryptors.rb
crypt_keeper-1.1.0 spec/support/encryptors.rb
crypt_keeper-1.0.1 spec/support/encryptors.rb
crypt_keeper-1.0.0 spec/support/encryptors.rb
crypt_keeper-1.0.0.beta1 spec/support/encryptors.rb