AWS KMS - Shop / Using Crypttext Blob

I simply configure myself using AWS Key Management and invoke the method generateDataKey. This method works and returns CiphertextBlob and Plaintext blob.

However, blobs are formatted something like this:

 g '  w i <  a*\B4p 1IG

I use the API, so according to the docs, it is not encoded. I'm trying to figure out if Plaintext can somehow be "decoded" in PHP, so I can store / use it without any odd ASCII characters. What I expected is a long string of characters, not the special characters above. I feel that I am missing something simple.

Thank!

+4
source share
1 answer

- blob. base64, .

:   

use Aws\Kms\KmsClient;

$options = [
    'region'                => 'eu-west-1',
    'version'               => '2014-11-01',
    'profile'               => 'default',
    'retries'               => 0,
    'scheme'                => 'https',
    'debug'                 => false
];

$kmsClient = new KmsClient($options);

$result = $kmsClient->generateDataKey([
    'KeyId' => '12345678-1234-1233-1234-1234567890ab',
    'KeySpec' => 'AES_256'
]);

echo base64_encode($result["CiphertextBlob"]);
echo "\r\n";
echo ($result["KeyId"]);
+1

All Articles