download: cryptobox.txt (save as cryptobox.pl)
cryptbox.pl is a simple script wrapping OpenSSL's AES library to write/read encrypted files.
In particular, I wrote this so as to provide an easier way to securely encrypt messages that must be sent over unsecure lines. Simply make an encrypted file and send it like any other... however, the security provided relies entirely on the key used. For this to be useful, two groups must have coordinated in advance and preferably securely, a pre-shared key to use.
To use cryptbox.pl it requires an implementation of perl and openssl installed. The particular perl modules are:
There are two modes, either reading an encrypted boxfile or writing one. Thus the script always requires an argument, which is the boxfile name. It can be named anything.
perl cryptbox.pl newboxfile
You are then prompted for the text which can be anything, but stops recording when you type "enter" twice.
You then need to put in a key twice. The key can be anything. Your receiving party should know this key.
Your file "newboxfile" is ready to be sent by whatever method you prefer: email attachment, p2p, ftp, etc
perl cryptbox.pl receivedboxfile
You are prompted for the key... if the correct key is entered you will see your message in cleartext.
If you entered the wrong key, you will see encrypted garbage:
you can download this example box file to test cryptobox.pl; the key is "key".
here is the code, so you can see it's nothing special: