Anyone have made any module to encrypt/decrypt customers passwords in the database ? If no one have made this, can anyone recomend a good article how to use C# to ecrypt passawords in the database ? Thank you for your help.
Check out using MD5. Its one way encryption but all you have to do to check a users password is compare the hash of the entered password to the hash in the database.
Here is an article I used to get this working: http://aspnet.4guysfromrolla.com/articles/103002-1.aspx I added a function in the customersDB class called hashPassword, then just called it from everywhere I normally used the string password. I also changed the
datatypes in the database, stored procedures and class functions to use binary(16) or byte() as appropriate. FYI - you have to use byte(), not byte as the type. (it is an array of bytes, not just a byte type) Jason
I found an even better way to do this: http://support.microsoft.com/default.aspx?scid=kb;EN-US;308157 You will also notice you do not need to write your own hash function. Instead you can leave all the stored procs, tables, and class functions as strings and
use this: "You may want to store passwords securely in a database. You can use the FormsAuthentication class utility function named HashPasswordForStoringInConfigFile to encrypt the passwords before you store them in the database or configuration file." It's
in the system.web.security class and you just add the imports to any vb files which need to create the hashes.
Here's a simple function that encrypts any string into a MD5 hash string:
Public Function EncryptMD5(ByVal text As String) As String
Dim md5Hasher As New MD5CryptoServiceProvider
Dim encoder As String
encoder = BitConverter.ToString(md5Hasher.ComputeHash(Encoding.ASCII.GetBytes(text))).Replace("-", Nothing)
Return encoder
End Function
this uses the "System.Security.Cryptography" namespace -Frank
rmvenancio
Member
495 Points
99 Posts
Crypt Password
Apr 26, 2004 02:45 PM|LINK
LiquidEnforc...
Member
5 Points
1 Post
Re: Crypt Password
May 18, 2004 11:08 PM|LINK
jemery27
Member
40 Points
8 Posts
Re: Crypt Password
Jul 10, 2004 09:07 PM|LINK
jemery27
Member
40 Points
8 Posts
Re: Crypt Password
Jul 11, 2004 06:58 PM|LINK
webxcraz
Member
410 Points
82 Posts
Re: Crypt Password
Jul 15, 2004 03:00 PM|LINK
Public Function EncryptMD5(ByVal text As String) As String Dim md5Hasher As New MD5CryptoServiceProvider Dim encoder As String encoder = BitConverter.ToString(md5Hasher.ComputeHash(Encoding.ASCII.GetBytes(text))).Replace("-", Nothing) Return encoder End Functionthis uses the "System.Security.Cryptography" namespace -Frank