MD5 's C # implementation method, the custom MD5 method, completely skips the MD5 library on today's network, realizing the complete security of MD5 encryption.
MD5 Although very strong, but the use of bad can still be black. Simple numbers and letters of the short string MD5 encryption characters in the current network can be queried, that is, can be directly decrypted, MD5 library directly there. So MD5 's encryption still defines a rule for itself, which is more secure.
Take a look at the "Md5encodemamicode" in the "Custom MD5 method" In the example below, a simple way to implement ideas and a safer security approach.
Using system;using system.collections.generic;using system.linq;using system.text;using System.security.cryptography;namespace m_class{//<summary>//[MD5 encryption][mamicode.com provided]//</summary& Gt public class Md5code {//<summary>//[constructors]///</summary> public Md5code () {}//<summary>///default encryption///</summary>//<param name= "str" >&L t;/param>//<returns></returns> public static string Md5encode (String str) { return md5encode32 (str); }///<summary>///32-bit MD5 algorithm encryption///</summary>//<param name= "str" > strings that need to be encrypted </param>///<returns> encrypted string </returns> public static string Md5encode32 (String str) {String password = ""; &NBSP;MD5 MD5 = MD5. Create (); &NBsp;byte[] s = MD5. ComputeHash (Encoding.UTF8.GetBytes (str)); foreach (byte b in s) &NBS P password + = b.tostring ("X2"); return password; } #region Custom MD5 method///<summary>//Mamicode MD5 encryption///</summary> <param name= "UID" > User id</param>//<param name= "Mamicodepwd" > string to be encrypted </param>// /<returns> Encrypted string </returns> public static string Md5encodemamicode (String uid, string mamicodepwd) {///Encryption Rule Description: 3 steps///1th Step: MD5 encryption for PWD///2nd Step: Stitching new string, user id+pwd+ 1th Step encrypted string takes 5th bit start 15 characters 3rd Step: The 2nd Step stitching string Once again MD5 encrypted string Secretkey1 = Md5encode32 (MAMICODEPWD); String Secretkey2 = uid + Secretkey1 + secretkey1.substring (5, 15); String Secretkey3 = Md5encode32 (Secretkey2); return Secretkey3; } #endregion}}
MD5 is the most commonly used cryptographic algorithm for verifying data integrity, and C # implements the MD5 method