From 6c027b4de25a529908be895e7ff19236f4002a57 Mon Sep 17 00:00:00 2001 From: Jérémy Zurcher Date: Fri, 9 Jul 2010 12:32:17 +0200 Subject: initial commit, resurrect one of my realy old projects --- mypass | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100755 mypass (limited to 'mypass') diff --git a/mypass b/mypass new file mode 100755 index 0000000..e524b2c --- /dev/null +++ b/mypass @@ -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 -- cgit v1.2.3