Class: Udongo::Crypt
- Inherits:
-
Object
- Object
- Udongo::Crypt
- Defined in:
- lib/udongo/crypt.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #crypt ⇒ Object
- #decrypt(value) ⇒ Object
- #encrypt(value) ⇒ Object
-
#initialize(secret: Rails.configuration.secret_key_base) ⇒ Crypt
constructor
A new instance of Crypt.
Constructor Details
#initialize(secret: Rails.configuration.secret_key_base) ⇒ Crypt
Returns a new instance of Crypt.
4 5 6 |
# File 'lib/udongo/crypt.rb', line 4 def initialize(secret: Rails.configuration.secret_key_base) @options = { secret: secret } end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
2 3 4 |
# File 'lib/udongo/crypt.rb', line 2 def @options end |
Instance Method Details
#crypt ⇒ Object
8 9 10 |
# File 'lib/udongo/crypt.rb', line 8 def crypt @crypt ||= ActiveSupport::MessageEncryptor.new([:secret]) end |
#decrypt(value) ⇒ Object
16 17 18 |
# File 'lib/udongo/crypt.rb', line 16 def decrypt(value) crypt.decrypt_and_verify(value) end |
#encrypt(value) ⇒ Object
12 13 14 |
# File 'lib/udongo/crypt.rb', line 12 def encrypt(value) crypt.encrypt_and_sign(value) end |