I'm writting a program to give a user a unique password based on his email address and i found this piece of code online. I'm now trying to reverse the code so that i can get back the email address from the password, pls can anyone tell me start with the decoding.
static char [] ValidChars = { '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9' , 'A' , 'B' , 'C' , 'D' , 'E' , 'F' , 'G' , 'H' , 'J' , 'K' , 'L' , 'M' , 'N' , 'P' , 'Q' , 'R' , 'S' , 'T' , 'U' , 'V' , 'W' , 'X' , 'Y' , 'Z' };
const string hashkey = "password" ;
const int codelength = 6 ;
string GetCodeForEmail ( string address )
{
byte [] hash ;
using ( HMACSHA1 sha1 = new HMACSHA1 ( ASCIIEncoding . ASCII .GetBytes ( hashkey ))) hash = sha1 . ComputeHash ( UTF8Encoding . UTF8 . GetBytes ( address )); int startpos = hash [ hash . Length - 1 ] % ( hash . Length - codelength ); StringBuilder passbuilder = new StringBuilder (); for ( int i = startpos ; i < startpos + codelength ; i ++) passbuilder . Append ( ValidChars [ hash [ i ] % ValidChars . Length ]); return passbuilder . ToString (); }