Cloud KMS takes as input, and returns as output, content that has been encoded using Base64 encoding.
For example, the following example shows the base64-encoded result for the quote, "You can observe a lot by watching. --Yogi Berra":
WW91IGNhbiBvYnNlcnZlIGEgbG90IGJ5IHdhdGNoaW5nLiAtLVlvZ2kgQmVycmEK
Encoding Content as Base64
To base64-encode a file and store the contents in a new file:
Linux
Encode the file using the base64 command line tool, making sure to
prevent line-wrapping by using the -w 0
flag:
$ base64 source_file -w 0 > encoded_file
In the JSON for your request, include the base64-encoded content. For example, when calling the encrypt method:
{ "plaintext": "U3VwZXIgc2VjcmV0IHRleHQgdGhhdCBtdXN0IGJlIGVuY3J5cHRlZAo=", }
Mac OSX
Encode the file using the base64 command line tool:
$ base64 source_file > encoded_file
In the JSON for your request, include the base64-encoded content. For example, when calling the encrypt method:
{ "plaintext": "U3VwZXIgc2VjcmV0IHRleHQgdGhhdCBtdXN0IGJlIGVuY3J5cHRlZAo=", }
Windows
Encode the audio file using the Base64.exe tool with the -e
option:
C:> Base64.exe -e source_file > encoded_file
In the JSON for your request, include the base64-encoded content. For example, when calling the encrypt method:
{ "plaintext": "U3VwZXIgc2VjcmV0IHRleHQgdGhhdCBtdXN0IGJlIGVuY3J5cHRlZAo=", }
Decoding Base64-Encoded Content
To decode a base64-encoded file and store the contents in a new file:
Linux
Decode the file using the base64 command line tool with the --decode
option:
$ base64 --decode encoded_file > decoded_file
Mac OSX
Decode the file using the base64 command line tool with the --decode
option:
$ base64 --decode encoded_file > decoded_file
Windows
Decode the audio file using the Base64.exe tool with the -d
option:
C:> Base64.exe -d encoded_file > decoded_file