Reputation: 143
I am in the process of increasing a sites security to include sha256 encryption along with a salt in a classic ASP page. to do this i am using code from this site. http://www.freevbcode.com/ShowCode.asp?ID=2565
I will eventually upgrade the site to .net so i want to make sure i can match the encrypted password in both classic asp and .net.
In classic asp i am calling the encryption like so.
GeneratedNewPassword = SHA256(Password & Random & NewGuid)
and generated a password of this: 2551baf9ab959dcb4224b3c3080b5888e0866be1a53f4a123645b71020272a3c
I then tried to create this same thing in .net
string hashedPassword = Security.HashSha1(password + random + dbUserGuid);
SHA256 sha256 = SHA256Managed.Create(); //utf8 here as well
byte[] bytes = sha256.ComputeHash(Encoding.UTF8.GetBytes(password + random + dbUserGuid));
string result = Convert.ToBase64String(bytes);
Which generated a string like this: fzC5FX4ShhZrdqy8MVM7PPVnW4D2gaX6DlinPDRFT2I=
I am guessing it has something to do with the utf that I am using, but not sure. Any help would be appreciated.
Upvotes: 1
Views: 1161
Reputation: 143
I figured out my mistake. My guid coming in from my database in classic asp was upper case and in .net it was lower case. Once I did a toUpper on the incoming guid my hashes matched.
Thanks for the help.
Upvotes: 0