Skip to content
Permalink
master
Switch branches/tags
Go to file
 
 
Cannot retrieve contributors at this time
executable file 11 lines (11 sloc) 543 Bytes
#!/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}"