Skip to content

Instantly share code, notes, and snippets.

@salif
Forked from johnnyopao/encrypt-all.sh
Created April 8, 2019 22:23
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 salif/2372916e681c29fac18062f25a6a7a52 to your computer and use it in GitHub Desktop.
Save salif/2372916e681c29fac18062f25a6a7a52 to your computer and use it in GitHub Desktop.
GPG Encrypt all files in directory
#!/bin/bash
# This uses gpg to encrypt every file in a directory as separate
# encrypted files
# Usage
# ./encrypt-all.sh ./dir-of-files-to-encrypt "PASSPHRASE"
FILES="$1"
PASSPHRASE="$2"
pushd $FILES
for file_name in ./*; do
enc_name="$file_name.enc"
echo "Encrypting $file_name"
gpg \
--passphrase "$PASSPHRASE" \
--batch \
--output "$file_name.enc" \
--symmetric \
--cipher-algo AES256 \
"$file_name"
echo "Done! Output: $enc_name"
done
popd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment