From: http://zhidao.baidu.com/question/151518268.html
Using system;
Using system. Collections. Generic;
Using system. text;
Using system. Web;
/// <Summary>
/// Use MD5AlgorithmEncryption (irreversible, cannot be decrypted)
/// Add this method to the CS page and call it directly.
/// </Summary>
/// <Param name = "password"> plaintext </param>
/// <Returns> ciphertext </returns>
Public static string encryptionmd5 (string password)
{
System. Security. cryptography. MD5 MD5 = system. Security. cryptography. md5.create ();
Byte [] bytes = new byte [16];
System. Text. asciiencoding ASC = new system. Text. asciiencoding ();
Bytes = md5.computehash (ASC. getbytes (password ));
Return convert. tobase64string (bytes );
}
///
// use the sha1 Algorithm for encryption (irreversible, undecrypted)
///
/// plaintext
/// ciphertext
Public static string encryptionsha1 (string text)
{< br> return system. web. security. formsauthentication. hashpasswordforstoringinconfigfile (text, "sha1");
}