Class: KmsEncrypted::Client
- Inherits:
-
Object
- Object
- KmsEncrypted::Client
- Defined in:
- lib/kms_encrypted/client.rb
Instance Attribute Summary collapse
-
#data_key ⇒ Object
readonly
Returns the value of attribute data_key.
-
#key_id ⇒ Object
readonly
Returns the value of attribute key_id.
Instance Method Summary collapse
- #decrypt(ciphertext, context: nil) ⇒ Object
- #encrypt(plaintext, context: nil) ⇒ Object
-
#initialize(key_id: nil, legacy_context: false, data_key: false) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(key_id: nil, legacy_context: false, data_key: false) ⇒ Client
Returns a new instance of Client.
5 6 7 8 9 |
# File 'lib/kms_encrypted/client.rb', line 5 def initialize(key_id: nil, legacy_context: false, data_key: false) @key_id = key_id || KmsEncrypted.key_id @legacy_context = legacy_context @data_key = data_key end |
Instance Attribute Details
#data_key ⇒ Object (readonly)
Returns the value of attribute data_key.
3 4 5 |
# File 'lib/kms_encrypted/client.rb', line 3 def data_key @data_key end |
#key_id ⇒ Object (readonly)
Returns the value of attribute key_id.
3 4 5 |
# File 'lib/kms_encrypted/client.rb', line 3 def key_id @key_id end |
Instance Method Details
#decrypt(ciphertext, context: nil) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/kms_encrypted/client.rb', line 23 def decrypt(ciphertext, context: nil) event = { key_id: key_id, context: context, data_key: data_key } ActiveSupport::Notifications.instrument("decrypt.kms_encrypted", event) do client.decrypt(ciphertext, context: context) end end |
#encrypt(plaintext, context: nil) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/kms_encrypted/client.rb', line 11 def encrypt(plaintext, context: nil) event = { key_id: key_id, context: context, data_key: data_key } ActiveSupport::Notifications.instrument("encrypt.kms_encrypted", event) do client.encrypt(plaintext, context: context) end end |