summaryrefslogtreecommitdiffstats
path: root/mypass
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2010-07-09 12:32:17 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2010-07-09 12:32:17 +0200
commit6c027b4de25a529908be895e7ff19236f4002a57 (patch)
treef70d3a400bbb9ba8a83e9d4ffcaa4b6e367fc8bb /mypass
downloadcrypto-6c027b4de25a529908be895e7ff19236f4002a57.zip
crypto-6c027b4de25a529908be895e7ff19236f4002a57.tar.gz
initial commit, resurrect one of my realy old projects
Diffstat (limited to 'mypass')
-rwxr-xr-xmypass57
1 files changed, 57 insertions, 0 deletions
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