MD5 is the most commonly used cryptographic algorithm for verifying data integrity, and C # implements the MD5 method

Source: Internet
Author: User
Tags md5 encryption

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" &GT;&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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.