Great job! I've been using one that I found online here –>
http://regex.info/code/sha1.lua (Made by Jeffrey Friedl)
It's far longer, but it does include the ability to use a custom key. In case anyone's interested in trying it out, I'll link to the programs I use to test it out.
hash –>
http://pastebin.com/SqGfsU95 –creates a hash from a key and text
crack –>
http://pastebin.com/TVhA9zq2 –attempts to crack the hash with a brute force dictionary attack
english-words –>
http://www.mediafire.com/?y9gio9yhcbbebys –list of 500 000 english words, required for brute force dictionary attack. Uses Canadian words, as I'm in Canada.
Unfortunately, the guy who made this code doesn't seem to like lua, and the code seems rather messy, at least to me. I wouldn't even know where to start trying to program an encryption algorithm, so maybe this code is really efficient afterall. The point is to show how difficult it is to crack SHA-1, even when you know the key. The 'crack' program will find the hashed phrase eventually, but only if it is passed the correct key, and the phrase happens to be a single word in the dictionary. It can easily be foiled by not using a dictionary word, or keeping the key a secret.
I don't know how difficult it is to do, but if you can, could you try to find a way to add the ability to encrypt with a custom key. I started this post simply to ask that, then figured I'd link to an example to help you out if you're interested, then figured I'd upload my programs to help test it out. Anyway, I hope you learn something, and maybe someday I'll try to figure out how all this works :P/>