Des encryption and decryption source code C # key value

Source: Internet
Author: User

The company's Protocol security requirements require des and md5 encryption for the transmitted content. This is because I was a newbie and was a little dizzy when I handed it over to me. We started to find various des encrypted content on the Internet. Because I don't understand it, I think I need to understand the principles, and finally I am confused by the time. Of course, if you are interested in strong logic, you can try it out. There are many encryption methods on the Internet. as developers, you only need to know how to use them. The first time I wrote articles, beautiful statements, and so on, I would like to show myself ugly again. Let's go straight into the question. First paste the source Code for encryption and decryption: View Code is the first contact with des and the requirements of the company's Protocol documentation, so I am confused about this Code: 1: the two parameters Text are the sKey of the content to be encrypted as the key of the encrypted content. Of course, the sKey values during encryption and decryption must be consistent. 2: The key value of the des object. The key value and the IV value are fixed 8-bit lengths, so be sure to keep them in mind. Because our parameter sKey is of an indefinite length, we adopt MD5 encryption and then intercept the first eight digits. This is to ensure key consistency during decryption. Otherwise, the decryption fails. Finally, let me talk about some of the things that I remember as a newbie, maybe some of the things necessary to write des in the eyes of many people ~~ Don't spray me, a few necessary objects: DESCryptoServiceProvider doesn't have it. What do you think about des? The Stream object CryptoStream stored in memory defines linking data streams to encrypted conversion streams. It writes the MemoryStream object and finally converts it to a String. This is the case. I also have a lot of questions. You are welcome to discuss them with us.

Related Article

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.