views:

66

answers:

1

I'm planning to use this piece of code in my Asp.net app

string strUserInputtedHashedPassword = FormsAuthentication.HashPasswordForStoringInConfigFile(tbPassword.Text, "sha1");
if(strUserInputtedHashedPassword == GetUsersHashedPasswordUsingUserName(tbUserName.Text))
{
   // sign-in successful
}
else
{
   // sign-in failed
}

Is the Hashing machine dependent... In the sense, If I create some users in my development machine in my development DB... Once I post both DB and Application to production environment with the user table, will the password for the users be same...

Hope I made my question clearly... Otherwise, please let me know..

Thanks

A: 

The hash is encoded and decoded using the machineKey in the machine.config, if you want the key to work against all tiers, make sure the keys in the machine.config files match.

This is basically the same problem you encounter with a web farm serving requests and validating each other's cookies...same solution.

Nick Craver
I may sound stupid... But can I set up Machine key in Web.config... I dont think I will have access to Machine.Config of production machine...
The King
@The King - Yes, this article describes how to do just that: http://msdn.microsoft.com/en-us/library/ms998288.aspx
Nick Craver
Great Resource... Thanks...
The King