diff options
Diffstat (limited to 'mypass')
-rwxr-xr-x | mypass | 57 |
1 files changed, 57 insertions, 0 deletions
@@ -0,0 +1,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 |