Saturday, March 24, 2012

md5() function / method for c#

is there something built in to the framework to create md5 hashes for c#?

php has a function named (of course) md5() that creates the hash of a mixed type.

take a look here:

http://www.kbcafe.com/iBLOGthere4iM/?guid=20040923142406

System.Security.Cryptography.MD5CryptoServiceProvider x = new System.Security.Cryptography.MD5CryptoServiceProvider();
byte[] bs = System.Text.Encoding.UTF8.GetBytes(password);
bs = x.ComputeHash(bs);
System.Text.StringBuilder s =new System.Text.StringBuilder();
foreach (byte bin bs)
{
s.Append(b.ToString("x2").ToLower());
}
password = s.ToString();


See classes in System.Security.Cryptography namespace, especiallyMD5CryptoServiceProvider
thank you pkellner, that worked perfectly.

your welcome. Always nice to find working code.

0 comments:

Post a Comment