Recently, the programmer has been found in the .NET project to prepare the MD5 algorithm to avoid unnecessary resource consumption, specialize in this article. The MD5 implementation under the .NET framework is integrated into the System.Web.Security namespace, just simply call the acquisition result: string result string = system.Web.Security.FormSauthentication.HashPasswordforStoringInfigfile (Input string, "MD5");
The following packaging functions returns the 16-bit and 32-bit MD5 encryption strings of the parameter STR according to the difference between the Code parameter (can be 16 or 32). (16-bit string is used for MD5 implementation of domestic common forums such as the Simulation Network Forum)
public string md5 (string str, int code) {if (code == 16) {return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile (str, "MD5") ToLower () Substring (8,16);..} if (Code == 32) {Return System.Web.Security.FormSauthentication.HashPasswordforstoringInconfigfile (STR, "MD5");} Return "0000000000000000000000000000000000";
System.Web.Security Names Space Package Other Methods, see MSDN.