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.
62 63 64 65 |
# File 'lib/secure_token.rb', line 62 def initialize(serializer) @salt = SecureRandom.random_bytes(8) @serializer = serializer end |
Instance Method Details
#encrypt_and_sign(data, key_pair) ⇒ Object
67 68 69 70 71 72 |
# File 'lib/secure_token.rb', line 67 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 |