Skip to content

Instantly share code, notes, and snippets.

@project0
Created November 2, 2020 17:34
Show Gist options
  • Save project0/99006ac19655efbc41e2b15c36808876 to your computer and use it in GitHub Desktop.
Save project0/99006ac19655efbc41e2b15c36808876 to your computer and use it in GitHub Desktop.
AWS KMS encryption/decryption
#!/bin/bash
function awskmsencrypt() {
key="$1"
text="$2"
aws kms encrypt --key-id "$key" --plaintext fileb://<(echo "$text") --output text --query CiphertextBlob
}
function awskmsdecrypt() {
crypt="$1" #base64
aws kms decrypt --ciphertext-blob fileb://<(echo "$crypt" | base64 -d) --output text --query Plaintext | base64 -d
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment