Skip to content

Instantly share code, notes, and snippets.

@mlehner616
Last active July 26, 2017 21:25
Show Gist options
  • Save mlehner616/28e6279a8f3d0317ef5b0d10c1de7c30 to your computer and use it in GitHub Desktop.
Save mlehner616/28e6279a8f3d0317ef5b0d10c1de7c30 to your computer and use it in GitHub Desktop.
aws-kms-crypt.sh
# Usage:
# encrypt kms-key-id plaintext
function encrypt () {
key_id=$1
plaintext=$2
aws kms encrypt --key-id $key_id --plaintext fileb://<(echo $plaintext) --query CiphertextBlob --output text
}
# Usage:
# decrypt ciphertext
function decrypt () {
ciphertext=$1
aws kms decrypt --ciphertext-blob fileb://<(echo $ciphertext | base64 --decode) --output text --query Plaintext | base64 --decode
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment