Class: Avo::Services::EncryptionService
- Inherits:
-
Object
- Object
- Avo::Services::EncryptionService
- Defined in:
- lib/avo/services/encryption_service.rb
Class Method Summary collapse
Instance Method Summary collapse
- #decrypt ⇒ Object
- #encrypt ⇒ Object
-
#initialize(message:, purpose:, **kwargs) ⇒ EncryptionService
constructor
A new instance of EncryptionService.
Constructor Details
#initialize(message:, purpose:, **kwargs) ⇒ EncryptionService
Returns a new instance of EncryptionService.
14 15 16 17 18 |
# File 'lib/avo/services/encryption_service.rb', line 14 def initialize(message:, purpose:, **kwargs) @message = @purpose = purpose @crypt = ActiveSupport::MessageEncryptor.new(encryption_key, **kwargs) end |
Class Method Details
.decrypt ⇒ Object
9 10 11 |
# File 'lib/avo/services/encryption_service.rb', line 9 def decrypt(...) new(...).decrypt end |
.encrypt ⇒ Object
5 6 7 |
# File 'lib/avo/services/encryption_service.rb', line 5 def encrypt(...) new(...).encrypt end |
Instance Method Details
#decrypt ⇒ Object
24 25 26 |
# File 'lib/avo/services/encryption_service.rb', line 24 def decrypt @crypt.decrypt_and_verify(@message, purpose: @purpose) end |
#encrypt ⇒ Object
20 21 22 |
# File 'lib/avo/services/encryption_service.rb', line 20 def encrypt @crypt.encrypt_and_sign(@message, purpose: @purpose) end |