I have written a quick console app to quickly go and generate usernames and logins for my web application for existing accounts that did not have properly hashed passwords. In my web application I am using FormsAuthentication like so:
string hashedPwd = FormsAuthentication.HashPasswordForStoringInConfigFile(saltAndPassword, "SHA1");
I tried to use FormsAuthentication in the console app but it cannot resolve the FormsAuthentication nor the imports. The warning I get asks if I am missing an assembly. I tried to use the following to give me the same results as the previous:
SHA1 sha1 = new SHA1CryptoServiceProvider();
System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
byte[] bytesHashedPwd = sha1.ComputeHash(encoding.GetBytes(saltAndPwd));
string tmpString = encoding.GetString(byteshashedPwd);
string hashedPwd = String.Concat(str, salt);
return hashedPwd;
These two methods are giving me different results. I need to get the same result as FormsAuthentication. I am no security expert with a tiny vauge background and my character set knowledge is even worse. I apprecaite any help.