Class: RailsMasterKeyKmsDecrypter::Decryption

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_master_key_kms_decrypter/decryption.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client_options) ⇒ Decryption

Returns a new instance of Decryption.



10
11
12
# File 'lib/rails_master_key_kms_decrypter/decryption.rb', line 10

def initialize(client_options)
  @client = Aws::KMS::Client.new(client_options)
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



8
9
10
# File 'lib/rails_master_key_kms_decrypter/decryption.rb', line 8

def client
  @client
end

Instance Method Details

#decrypt(value, **options) ⇒ Object



14
15
16
17
18
# File 'lib/rails_master_key_kms_decrypter/decryption.rb', line 14

def decrypt(value, **options)
  decoded = Base64.strict_decode64(value)
  response = client.decrypt(ciphertext_blob: decoded, **options)
  response.plaintext
end