Permalink
Cannot retrieve contributors at this time
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
executable file
11 lines (11 sloc)
543 Bytes
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
#!/usr/bin/env bash | |
# Use: ./encrypt-multi.sh file1 file2 ... | |
PASSWORDLIST=$(mktemp) | |
while [[ $# -gt 0 ]]; do # While there are files to encrypt... | |
FILENAME="$1"; shift # ...take next filename... | |
openssl rand -base64 32 >>"${PASSWORDLIST}" # ...add new secure password... | |
readarray PASS <"${PASSWORDLIST}" # ...read back passwords... | |
openssl aes-256-cbc -pass "pass:${PASS[${#PASS[@]}]}" -a -salt -in "${FILENAME}" -out "${FILENAME##*/}.enc" # ...encrypt file with the last password. | |
done | |
cat "${PASSWORDLIST}" | |
rm "${PASSWORDLIST}" |