SHA1 Encryption Algorithm

Source: Internet
Author: User
/// <Summary> /// create an object by using the new operator /// <summary> /// <param name = "strSource"> plaintext to be encrypted </param> /// <returns> returns the 16-bit encryption result, the result is a 32-bit encryption result with 9th to 25 digits </returns> public string SHA1EncryptData (string strSource) {// new System. security. cryptography. SHA1 sha = new System. security. cryptography. SHA1CryptoServiceProvider (); // obtain the ciphertext byte array byte [] bytResult = sha. computeHash (System. text. encoding. default. getBytes (strSource); // convert it to a string and take 9 to 25 digits. // string strResult = BitConverter. toString (bytResult, 4, 8); // converts the string to a 32-Bit string strResult = BitConverter. toString (bytResult); // The character string converted by BitConverter will generate a separator between each character. strResult = strResult must be removed. replace ("-", ""); return strResult ;}

 

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.