Last active
November 14, 2019 00:50
-
-
Save mesmacosta/b2b7febbcc08de7c87adc5be5980b2b0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| MYDIR=allen-p | |
| FILES=$(find $MYDIR -type f -not -name "*.encrypted") | |
| for file in $FILES; do | |
| PLAINTEXT=$(cat $file | base64 -w0) | |
| curl -v "https://cloudkms.googleapis.com/v1/projects/$DEVSHELL_PROJECT_ID/locations/global/keyRings/$KEYRING_NAME/cryptoKeys/$CRYPTOKEY_NAME:encrypt" \ | |
| -d "{\"plaintext\":\"$PLAINTEXT\"}" \ | |
| -H "Authorization:Bearer $(gcloud auth application-default print-access-token)" \ | |
| -H "Content-Type:application/json" \ | |
| | jq .ciphertext -r > $file.encrypted | |
| done | |
| gsutil -m cp allen-p/inbox/*.encrypted gs://${BUCKET_NAME}/allen-p/inbox |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| curl -v "https://cloudkms.googleapis.com/v1/projects/$DEVSHELL_PROJECT_ID/locations/global/keyRings/$KEYRING_NAME/cryptoKeys/$CRYPTOKEY_NAME:decrypt" \ | |
| -d "{\"ciphertext\":\"$(cat 1.encrypted)\"}" \ | |
| -H "Authorization:Bearer $(gcloud auth application-default print-access-token)"\ | |
| -H "Content-Type:application/json" \ | |
| | jq .plaintext -r | base64 -d |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| curl -v "https://cloudkms.googleapis.com/v1/projects/$DEVSHELL_PROJECT_ID/locations/global/keyRings/$KEYRING_NAME/cryptoKeys/$CRYPTOKEY_NAME:encrypt" \ | |
| -d "{\"plaintext\":\"$PLAINTEXT\"}" \ | |
| -H "Authorization:Bearer $(gcloud auth application-default print-access-token)"\ | |
| -H "Content-Type: application/json" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment