Skip to content

Instantly share code, notes, and snippets.

@chaoyangnz
Created September 1, 2019 23:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chaoyangnz/724f066579a53c70a9d0a9e57631d6d8 to your computer and use it in GitHub Desktop.
Save chaoyangnz/724f066579a53c70a9d0a9e57631d6d8 to your computer and use it in GitHub Desktop.

Put these two functions into your ~/.bashrc or ~/.zshrc

decrypt_secret() {
	if [ "$#" -ne 2 ]; then
	  echo "Usage: decrypt_secret <secret.yaml> <passphrase>"
	  return 1
	fi
	openssl enc -aes-256-cbc -d -base64 -in "$1.aes256" -out "$1" -k "$2"
}

encrypt_secret() {
	if [ "$#" -ne 2 ]; then
	  echo "Usage: encrypt_secret <secret.yaml> <passphrase>"
	  return 1
	fi
	openssl enc -aes-256-cbc -e -base64 -in "$1" -out "$1.aes256" -k "$2"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment