C # ASE Encryption decryption

Source: Internet
Author: User

More commonly used encryption methods in the project

     /// <summary>    ///ase_128_ecb_ No Fill _64base_ encryption function/// </summary>    /// <param name= "Content" >the content to encrypt</param>    /// <param name= "key" >Be sure to have a 16-bit key</param>    /// <returns>encrypted string (bytes)</returns>     Public Static byte[] func_aes128 encryption (stringContentstringkey) {        byte[] Keyarray =UTF8Encoding.UTF8.GetBytes (key); byte[] Toencryptarray =UTF8Encoding.UTF8.GetBytes (content); RijndaelManaged Rdel=Newrijndaelmanaged (); Rdel.key=Keyarray; Rdel.mode=CIPHERMODE.ECB; Rdel.padding=PADDINGMODE.PKCS7; ICryptoTransform Ctransform=Rdel.createencryptor (); byte[] Resultarray = Ctransform.transformfinalblock (Toencryptarray,0, toencryptarray.length); //returns a byte array that can be converted to bytes using convert.frombase64string ()//return convert.tobase64string (resultarray, 0, resultarray.length);         returnResultarray; }    /// <summary>    ///ase_128_ecb_ No Fill _64base_ decryption function/// </summary>    /// <param name= "Content" >secret String (bytes)</param>    /// <param name= "Keyarray" >Key (bytes)</param>    /// <returns>the decrypted string</returns>     Public Static byte[] func_aes128 decryption (byte[] content,byte[] keyarray)#region{rijndaelmanaged Rdel=Newrijndaelmanaged (); Rdel.key=Keyarray; Rdel.mode=CIPHERMODE.ECB; Rdel.padding=Paddingmode.none; Rdel.blocksize= -; ICryptoTransform Ctransform=Rdel.createdecryptor (); byte[] resultarray = ctransform.transformfinalblock (content,0, content.        Length); returnResultarray; }    #endregionuse:byte[] _val1 = func_aes128 encryption ("Lee","abcdef1234567890"); byte[] _key = Encoding.UTF8.GetBytes ("abcdef1234567890"); byte[] _return1 =func_aes128 decryption (_val1, _key); TextBox2.Text= Encoding.UTF8.GetString (_RETURN1);

C # ASE Encryption decryption

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.