lunedì 13 settembre 2010

bash and perl / crypt and decrypt

Do you want make a fast unix script that crypt and decrypt string in your unix’s shell?
I like the cryptography and this is it my study for a fast and simple bash script that crypt and decrypt string in your unix’shell.
Here the code: file.sh
#!/bin/bash
#
# author.....: Alessandro Muratore
# email......: muratore.ale@gmail.com
#
case "$1" in
crypt)
 echo "insert string..:";
 read st
 cp='s/(.)/chr(ord($1)+3)/ge'
 echo ""
 echo "result.........:"
 echo $st | perl -pe $cp
 ;;
decrypt)
 echo "insert string..:"
 read st
 cd='s/(.)/chr(ord($1)-3)/ge'
 echo ""
 echo "result.........:"
 echo $st | perl -pe $cd
 ;;
*)
 echo "usage: file.sh [ crypt | decrypt ]"
 ;;
esac

Nessun commento:

Posta un commento