Class: Spree::Encryptor
- Inherits:
-
Object
- Object
- Spree::Encryptor
- Defined in:
- lib/spree/encryptor.rb
Overview
Spree::Encryptor is a thin wrapper around ActiveSupport::MessageEncryptor.
Instance Method Summary collapse
-
#decrypt(encrypted_value) ⇒ String
Decrypt an encrypted value.
-
#encrypt(value) ⇒ String
Encrypt a value.
-
#initialize(key) ⇒ Encryptor
constructor
A new instance of Encryptor.
Constructor Details
#initialize(key) ⇒ Encryptor
Returns a new instance of Encryptor.
7 8 9 |
# File 'lib/spree/encryptor.rb', line 7 def initialize(key) @crypt = ActiveSupport::MessageEncryptor.new(key) end |
Instance Method Details
#decrypt(encrypted_value) ⇒ String
Decrypt an encrypted value
21 22 23 |
# File 'lib/spree/encryptor.rb', line 21 def decrypt(encrypted_value) @crypt.decrypt_and_verify(encrypted_value) end |
#encrypt(value) ⇒ String
Encrypt a value
14 15 16 |
# File 'lib/spree/encryptor.rb', line 14 def encrypt(value) @crypt.encrypt_and_sign(value) end |