Class: SecureToken::SecureTokenHash
- Inherits:
-
HashWithIndifferentAccess
- Object
- HashWithIndifferentAccess
- SecureToken::SecureTokenHash
- Defined in:
- lib/secure_token.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from_token(token, key_pair) ⇒ Object
23 24 25 26 27 |
# File 'lib/secure_token.rb', line 23 def from_token(token, key_pair) decryptor = SecureTokenService::Decryptor.new(SecureTokenService::JSONSerializer.new) decrypted_token = decryptor.decrypt_and_verify(token, key_pair) decrypted_token ? new.merge(decrypted_token) : nil end |
Instance Method Details
#to_token(key_pair) ⇒ Object
30 31 32 33 |
# File 'lib/secure_token.rb', line 30 def to_token(key_pair) encryptor = SecureTokenService::Encryptor.new(SecureTokenService::JSONSerializer.new) encryptor.encrypt_and_sign(self, key_pair) end |