Class: SecureToken::SecureTokenService::Encryptor
- Inherits:
-
Object
- Object
- SecureToken::SecureTokenService::Encryptor
- Defined in:
- lib/secure_token.rb
Instance Method Summary collapse
- #encrypt_and_sign(data, key_pair) ⇒ Object
-
#initialize(serializer) ⇒ Encryptor
constructor
A new instance of Encryptor.
Constructor Details
#initialize(serializer) ⇒ Encryptor
Returns a new instance of Encryptor.
61 62 63 64 |
# File 'lib/secure_token.rb', line 61 def initialize(serializer) @salt = SecureRandom.random_bytes(8) @serializer = serializer end |
Instance Method Details
#encrypt_and_sign(data, key_pair) ⇒ Object
66 67 68 69 70 71 |
# File 'lib/secure_token.rb', line 66 def encrypt_and_sign(data, key_pair) serialized = @serializer.serialize(data) encrypted = encrypt(serialized, key_pair.encryption_key) signed = sign(encrypted, key_pair.signing_key) Base64.urlsafe_encode64(signed) end |