-
-
Save salif/2372916e681c29fac18062f25a6a7a52 to your computer and use it in GitHub Desktop.
GPG Encrypt all files in directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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