C#des Plus decryption

Source: Internet
Author: User
Tags decrypt

public static string key        {            get            {                return Key;            }            Set            {                key = value;            }        }

DES encryption

        <summary>//DES Encrypt//</summary>/<param name= "encr Yptstring "> Strings to be encrypted </param>//<returns> encrypted strings </returns> public static string Desencry PT (String encryptstring) {byte[] keybytes = System.Text.Encoding.UTF8.GetBytes (key.            Substring (0, 8));            byte[] Keyiv = keybytes;            byte[] Inputbytearray = Encoding.UTF8.GetBytes (encryptstring); System.Security.Cryptography.DESCryptoServiceProvider Provider = new            System.Security.Cryptography.DESCryptoServiceProvider ();            System.IO.MemoryStream mstream = new System.IO.MemoryStream (); System.Security.Cryptography.CryptoStream Cstream = new System.Security.Cryptography.CryptoStream (Mstream, provider .            CreateEncryptor (Keybytes, Keyiv), System.Security.Cryptography.CryptoStreamMode.Write);            Cstream.write (Inputbytearray, 0, inputbytearray.length); Cstream.flushfinalbloCK ();        Return convert.tobase64string (Mstream.toarray ());     }

  

Des decryption

         <summary>//Function:des Decrypt//</summary>/<param NA Me= "Decryptstring" > String to Decrypt </param>//<returns> decrypted string </returns> public static string Desdecrypt (String decryptstring) {byte[] keybytes = Encoding.UTF8.GetBytes (key.            Substring (0, 8));            byte[] Keyiv = keybytes;            byte[] Inputbytearray = convert.frombase64string (decryptstring); System.Security.Cryptography.DESCryptoServiceProvider Provider = new            System.Security.Cryptography.DESCryptoServiceProvider ();            System.IO.MemoryStream mstream = new System.IO.MemoryStream (); System.Security.Cryptography.CryptoStream Cstream = new System.Security.Cryptography.CryptoStream (Mstream, provider .            CreateDecryptor (Keybytes, Keyiv), System.Security.Cryptography.CryptoStreamMode.Write);            Cstream.write (Inputbytearray, 0, inputbytearray.length); Cstream.flushfinalblock();        Return Encoding.UTF8.GetString (Mstream.toarray ());   }

  

C#des Plus decryption

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.