
03.02.2008, 21:05
|
|
Участник форума
Регистрация: 01.12.2007
Сообщений: 141
Провел на форуме: 1208190
Репутация:
136
|
|
Код:
//метод для генерации md5 hash
public string EncodePassword(string originalPassword)
{
//Declarations
Byte[] originalBytes;
Byte[] encodedBytes;
MD5 md5;
//Instantiate MD5CryptoServiceProvider, get bytes for original password and compute hash (encoded password)
md5 = new MD5CryptoServiceProvider();
originalBytes = ASCIIEncoding.Default.GetBytes(originalPassword);
encodedBytes = md5.ComputeHash(originalBytes);
//Convert encoded bytes back to a 'readable' string
return BitConverter.ToString(encodedBytes);
}
ИМХО оптимальный метод.. И не забудь подключить using System.Security.Cryptography;
|
|
|