Class: ActiveRecordEncryption::Encryptor::ActiveSupport
- Defined in:
- lib/active_record_encryption/encryptor/active_support.rb
Instance Method Summary collapse
- #==(other) ⇒ Object
- #decrypt(value) ⇒ Object
- #encrypt(value) ⇒ Object
-
#initialize(key:, salt:, cipher: nil) ⇒ ActiveSupport
constructor
A new instance of ActiveSupport.
Constructor Details
#initialize(key:, salt:, cipher: nil) ⇒ ActiveSupport
Returns a new instance of ActiveSupport.
6 7 8 9 |
# File 'lib/active_record_encryption/encryptor/active_support.rb', line 6 def initialize(key:, salt:, cipher: nil) key_generator = ::ActiveSupport::KeyGenerator.new(key) @encryptor = ::ActiveSupport::MessageEncryptor.new(key_generator.generate_key(salt, 32), cipher: cipher) end |
Instance Method Details
#==(other) ⇒ Object
19 20 21 |
# File 'lib/active_record_encryption/encryptor/active_support.rb', line 19 def ==(other) super && encryptor == other.encryptor end |
#decrypt(value) ⇒ Object
15 16 17 |
# File 'lib/active_record_encryption/encryptor/active_support.rb', line 15 def decrypt(value) encryptor.decrypt_and_verify(super) end |
#encrypt(value) ⇒ Object
11 12 13 |
# File 'lib/active_record_encryption/encryptor/active_support.rb', line 11 def encrypt(value) encryptor.encrypt_and_sign(super) end |