Тема: C# Md5
Показать сообщение отдельно

  #2  
Старый 03.02.2008, 21:05
0x22b
Участник форума
Регистрация: 01.12.2007
Сообщений: 141
Провел на форуме:
1208190

Репутация: 136
Отправить сообщение для 0x22b с помощью ICQ
По умолчанию

Код:
//метод для генерации 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;