-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcipher.sh
More file actions
executable file
·23 lines (22 loc) · 780 Bytes
/
cipher.sh
File metadata and controls
executable file
·23 lines (22 loc) · 780 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env bash
enc=$1
if [ -z "$enc" ]; then
echo 'No file name is provided.'
else
tput smcup
if [ -f "$enc" ]; then
mv $enc ${enc}.old
base32 -d ${enc}.old > ${enc}.old.bin
read -sp 'Enter password: ' PASS
echo
{ printf '%s\n' "$PASS" | openssl enc -aes-256-ctr -pbkdf2 -d -kfile /dev/stdin -in ${enc}.old.bin ; cat ; } |
{ printf '%s\n' "$PASS" | openssl enc -aes-256-ctr -pbkdf2 -salt -kfile /dev/stdin -in /dev/fd/3 -out ${enc}.bin ; } 3<&0
unset PASS
base32 $enc.bin > $enc
rm ${enc}.old.bin $enc.bin
else
openssl enc -aes-256-ctr -pbkdf2 -salt | base32 > $enc
fi
tput rmcup
python "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"/Base32CJK.py -i $enc -o $(echo ${enc%.enc} | sed 's/.txt$//').CJK.txt
fi