class KmsEncrypted::Clients::Test
Constants
- PREFIX
Public Instance Methods
decrypt(ciphertext, context: nil)
click to toggle source
# File lib/kms_encrypted/clients/test.rb, line 12 def decrypt(ciphertext, context: nil) prefix, plaintext, stored_context = ciphertext.split(":") decryption_failed! if prefix != PREFIX context = generate_context(context) if context decryption_failed! if context != stored_context Base64.decode64(plaintext) end
encrypt(plaintext, context: nil)
click to toggle source
# File lib/kms_encrypted/clients/test.rb, line 6 def encrypt(plaintext, context: nil) parts = [PREFIX, Base64.strict_encode64(plaintext)] parts << generate_context(context) if context parts.join(":") end
Private Instance Methods
generate_context(context)
click to toggle source
turn hash into json
Calls superclass method
KmsEncrypted::Clients::Base#generate_context
# File lib/kms_encrypted/clients/test.rb, line 26 def generate_context(context) Base64.encode64(super) end