Module: RomEncryptedAttribute
- Defined in:
- lib/rom_encrypted_attribute.rb,
lib/rom_encrypted_attribute/version.rb,
lib/rom_encrypted_attribute/decryptor.rb,
lib/rom_encrypted_attribute/encryptor.rb,
lib/rom_encrypted_attribute/key_derivator.rb
Defined Under Namespace
Classes: Decryptor, Encryptor, KeyDerivator, Payload
Constant Summary collapse
- VERSION =
"0.0.3"
Class Method Summary collapse
Class Method Details
.define_encrypted_attribute_types(primary_key:, key_derivation_salt:, hash_digest_class: OpenSSL::Digest::SHA1) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/rom_encrypted_attribute.rb', line 11 def self.define_encrypted_attribute_types(primary_key:, key_derivation_salt:, hash_digest_class: OpenSSL::Digest::SHA1) key_derivator = KeyDerivator.new(salt: key_derivation_salt, secret: primary_key, hash_digest_class: hash_digest_class) reader_type = Dry.Types.Constructor(String) do |value| RomEncryptedAttribute::Decryptor.new(derivator: key_derivator).decrypt(value) end writer_type = Dry.Types.Constructor(String) do |value| RomEncryptedAttribute::Encryptor.new(derivator: key_derivator).encrypt(value) end [writer_type, reader_type] end |