Class: Avo::Services::EncryptionService

Inherits:
Object
  • Object
show all
Defined in:
lib/avo/services/encryption_service.rb

Class Method Summary collapse

Instance Method Summary collapse

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 = message
  @purpose = purpose
  @crypt = ActiveSupport::MessageEncryptor.new(encryption_key, **kwargs)
end

Class Method Details

.decryptObject



9
10
11
# File 'lib/avo/services/encryption_service.rb', line 9

def decrypt(...)
  new(...).decrypt
end

.encryptObject



5
6
7
# File 'lib/avo/services/encryption_service.rb', line 5

def encrypt(...)
  new(...).encrypt
end

Instance Method Details

#decryptObject



24
25
26
# File 'lib/avo/services/encryption_service.rb', line 24

def decrypt
  @crypt.decrypt_and_verify(@message, purpose: @purpose)
end

#encryptObject



20
21
22
# File 'lib/avo/services/encryption_service.rb', line 20

def encrypt
  @crypt.encrypt_and_sign(@message, purpose: @purpose)
end