Class: InfisicalSDK::CryptographyClient
- Inherits:
-
Object
- Object
- InfisicalSDK::CryptographyClient
- Defined in:
- lib/clients/cryptography.rb
Overview
Perform encryption
Instance Method Summary collapse
- #create_symmetric_key ⇒ Object
- #decrypt_symmetric(ciphertext:, iv:, tag:, key:) ⇒ Object
- #encrypt_symmetric(data:, key:) ⇒ Object
-
#initialize(command_runner) ⇒ CryptographyClient
constructor
A new instance of CryptographyClient.
Constructor Details
#initialize(command_runner) ⇒ CryptographyClient
Returns a new instance of CryptographyClient.
15 16 17 |
# File 'lib/clients/cryptography.rb', line 15 def initialize(command_runner) @command_runner = command_runner end |
Instance Method Details
#create_symmetric_key ⇒ Object
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/clients/cryptography.rb', line 52 def create_symmetric_key response = run_command(create_symmetric_key: ArbitraryOptions.new( data: '' )) key_response = ResponseForCreateSymmetricKeyResponse.from_json!(response).to_dynamic error_handler(key_response) key_response['data']['key'] end |
#decrypt_symmetric(ciphertext:, iv:, tag:, key:) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/clients/cryptography.rb', line 32 def decrypt_symmetric( ciphertext:, iv:, tag:, key: ) response = run_command(decrypt_symmetric: DecryptSymmetricOptions.new( ciphertext: ciphertext, iv: iv, tag: tag, key: key )) decrypt_response = ResponseForDecryptSymmetricResponse.from_json!(response).to_dynamic error_handler(decrypt_response) decrypt_response['data']['decrypted'] end |
#encrypt_symmetric(data:, key:) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/clients/cryptography.rb', line 19 def encrypt_symmetric(data:, key:) response = run_command(encrypt_symmetric: EncryptSymmetricOptions.new( key: key, plaintext: data, )) encrypt_response = ResponseForEncryptSymmetricResponse.from_json!(response).to_dynamic error_handler(encrypt_response) encrypt_response['data'] end |