views:

66

answers:

2

I have some server side code that needs to check a username/password pair. I'm looking for something to do this that is nice and simple as in having a text file with username/MD5 hash pairs. I'd love the code use to look like this:

if(!PasswordChecker.ValidLogin("passwords.dat", username, password)
   throw new Exception("Invalid username or password");
+1  A: 

I would look at using the ASP.NET Forms Authentication items.

You can call Membership.ValidateUser("MyUsername", "MyPassword") to validate the login.

You can store the username/password pairs in the web.config file. This would go in a section similar to this.

<credentials passwordFormat="MD5">
<user name="username" password="hashedpasswordhere"/>
<user name="username2" password="hashedpasswordhere"/>
</credentials>
Mitchel Sellers
that would work if I had a web.config and if I could use a single user set (and I'm not sure I can)
BCS
I can't imagine why you couldn't have a web.config, and you would need to have all users in the same text file if you went that route. YOu can add as many users as needed.
Mitchel Sellers
A: 

Using a .config file is nice because of the easy access to the information. However, if you choose not to do this, make sure that the file type you make is not able to be downloaded.

MasterMax1313