blob: e524b2ca0736d414f748893b6ceec87d0c14c923 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
#! /bin/sh
BIN="cryptot"
CIPHER="-c 2"
usage () {
echo "usage : `basename $0` -(e|d) input_file password [output_file]"
echo " -e : encryption."
echo " -d : decryption."
echo " if output_file is omited, output is written to stdout."
}
work () {
if [ "$1" == "-e" ];then
echo "encrypt : $2"
MODE=""
else
echo "decrypt : $2"
MODE="-x"
fi
echo "use password : $3"
if [ $# -eq 4 ]; then
echo "write output to : $4"
else
echo "write output to : stdout"
fi
echo "hit Enter to proceed. type Ctrl-C to abort."
read -t 5 A
if [ $? -ne 0 ]; then echo "=> timeout ... operation aborted." && exit; fi
CMD="${BIN} ${MODE} ${CIPHER} $3"
if [ $# -eq 4 ]; then
cat $2 | ${CMD} > $4
else
cat $2 | ${CMD}
fi
if [ "$1" == "-e" ];then
echo "hit Enter to remove $2. type Ctrl-C to abort."
read -t 4 A
if [ $? -ne 0 ]; then echo "=> timeout ... nothing done." && exit; fi
rm $2 $2~ 2>/dev/null
fi
}
if [ $# -lt 3 -o $# -gt 4 ]; then usage && exit; fi
if [ ! -f $2 ];then
echo "$2 isn't a regular file"
exit
fi
case "$1" in
"-e"|"-d")
work $@
;;
*)
echo $CHOICE
usage;;
esac
|