Simple Encryption and Decryption

You can use this script any way you want to; in fact it’s written with a few things left out (how you want to deal with shell special characters — another complete post on its own — and if you want to expand on it to read and/or write to STDIN/STDOUT so you can pipe one instance to another, even though that defeats the purpose to a certain degree).



I’ve included usage points in the comments section of the script, but the basic usage would be:

tranz.pl encode your message here
tranz.pl decode 458616e6b6370264f62702659637964796e6760245865602c496e657870216e6460255e6968702d456e6167656279656
<-- The Hex output from a message encoded with this script.




This work is licensed under a
Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License


#!/usr/bin/perl # # 2007 - Mike Golvach - eggi@comcast.net # Sanitize shell special characters in # whatever manner you prefer - or just # backslash them on the command line :) # # Sample usage: # trans.pl encode hi there # trans.pl encode hi there >FILE # trans.pl encode `cat FILE` # trans.pl decode 8696024786562756 # trans.pl decode `cat FILE` # # Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License # $input = $ARGV[0]; shift @ARGV; $message = join(" ",@ARGV); if ( $input eq "encode") { $output=unpack("h*",$message); @length=$output=~/.{0,256}/g; print("$output n"); } elsif ( $input eq "decode" ) { chomp($message); $output.=pack"h*",$message; print "n$outputn"; } else { print "Usage: (.*?) [encode|decode] whatever you want to typen"; exit(1) }



The Linux and Unix Menagerie: Simple Encryption and Decryption For Fun And No Profit.
Blogmarks BlogMemes BlogLines del.icio.us de.lirio.us Digg Facebook Google Google Reader LinkaGoGo Ask.com MyStuff Ask.com Yahoo! MyWeb Netscape Sphere StumbleUpon Plugin by Dichev.com

Leave a Comment