mirror of
https://github.com/gunchev/home_bin.git
synced 2025-11-20 12:15:46 +00:00
Add AES encryption/decryption with openssl
The scripts are a bit insecure, safe for home use, see the TODO.
This commit is contained in:
parent
20647b0ef8
commit
a84ef39ed8
2 changed files with 82 additions and 0 deletions
44
bash/AESDEC
Executable file
44
bash/AESDEC
Executable file
|
|
@ -0,0 +1,44 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "Usage: $0 file_to_decrypt.aes [another_file_to_decrypt.aes]*"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# TODO, use mktemp and -pass file:/tmp/tempfile to pass the password
|
||||
read -ersp "Enter password: " P
|
||||
echo
|
||||
|
||||
while [ ! -z "$1" ]; do
|
||||
INFILE="$1"
|
||||
OUTFILE="${1%.aes}"
|
||||
|
||||
if [ "$INFILE" = "$OUTFILE" ]; then
|
||||
echo "The input file does not end with .aes"
|
||||
shift
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ -e "$OUTFILE" ]; then
|
||||
echo "$OUTFILE exists, will not overwrite"
|
||||
shift
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ ! -f "$INFILE" ]; then
|
||||
echo "$INFILE does not exist, can not decrypt"
|
||||
shift
|
||||
continue
|
||||
fi
|
||||
|
||||
echo "Processing $INFILE..."
|
||||
if which bar > /dev/null 2>&1; then
|
||||
bar -dan -if "$INFILE" | openssl enc -d -aes-256-cbc -salt -pass pass:"$P" > "$OUTFILE"
|
||||
else
|
||||
echo -n "Please wait..."
|
||||
openssl enc -d -aes-256-cbc -salt -pass pass:"$P" < "$INFILE" > "$OUTFILE"
|
||||
echo " done."
|
||||
fi
|
||||
|
||||
shift
|
||||
done
|
||||
Loading…
Add table
Add a link
Reference in a new issue