Skip to content

Instantly share code, notes, and snippets.

@ryu1kn
Last active November 9, 2019 22:37
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 ryu1kn/e435b2ea79edba2798ab5048834dd0e0 to your computer and use it in GitHub Desktop.
Save ryu1kn/e435b2ea79edba2798ab5048834dd0e0 to your computer and use it in GitHub Desktop.
Encrypt/decrypt a directory using GPG with symmetric key option
# Encrypt/decrypt a directory using GPG with symmetric key option
dir_name := plain-files
encrypted_file := encrypted-dir.blob
tmp_file := tmp.tgz
encrypt-dir:
tar czf $(tmp_file) $(dir_name)
gpg --no-symkey-cache -o $(encrypted_file) -c $(tmp_file)
rm -f $(tmp_file)
decrypt-dir:
gpg -o $(tmp_file) -d $(encrypted_file)
tar xzf $(tmp_file)
rm -f $(tmp_file)
encrypt-string:
echo "MY TOP SECRET" | gpg --symmetric --armor --passphrase "$(MY_PASSWORD)" > encrypted.txt
decrypt-string:
cat encrypted.txt | gpg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment