I am a beginner to google cloud. I have a java code which uses KMS to encrypt some credential information. At last it returns the cyphertext (a String object), which is what i need. It gives me something like this:
CiQAUxKMC06hZ7cuhlqdQQPGdNJqotwoKlSzjKmr+kwR3iMLg04SZABqmWMTCukKk0EVIDa1PpqqSIszczXGvt+nQN/jpV3DLEjXH3xkzdL0an9kiRIfLHryhcFwaYt/DczI4sy4VdZSoyKcszzZyGdVjISsyIbMnYINuqme1sa7GqLM98cXfnYzHjE=
EncryptResponse response = kms.projects().locations().keyRings().cryptoKeys()
.encrypt(resourceName, request)
.execute();
return response.getCiphertext();
Now I also want a bootstrap script that could do the similar thing. However, when I use command line as follows. The content in the encryption.txt file is not nice looking as a String, but some unicode characters. Is there a way I could achieve the above nice encryption string by using gcloud kms command line?
export ENCRYPTION=$(gcloud kms encrypt --location=global --keyring=$KEYRING --key=$KEY --plaintext-file=text.txt --ciphertext-file=encryption.txt)
Google Cloud KMS uses Base64-encoded AES-256 encryption keys. You should be able to decode the cyphertext using the base64 library.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With