The C # script plus decryption method in the Unity3d project.
1. Encryption
1 /// <summary>2 3 ///Content Encryption4 5 /// </summary>6 7 /// <param name= "ContentInfo" >to encrypt content</param>8 9 /// <param name= "Strkey" >Key Value</param>Ten One /// <returns></returns> A - Public stringEncryptioncontent (stringContentInfo,stringstrkey) - the { - - byte[] Keyarray =UTF8Encoding.UTF8.GetBytes (strkey); - +RijndaelManaged encryption =Newrijndaelmanaged (); - +Encryption. Key =Keyarray; A atEncryption. Mode =CIPHERMODE.ECB; - -Encryption. Padding =PADDINGMODE.PKCS7; - -ICryptoTransform Ctransform =encryption. CreateEncryptor (); - in byte[] _encryptarray =UTF8Encoding.UTF8.GetBytes (contentinfo); - to byte[] Resultarray = Ctransform.transformfinalblock (_encryptarray,0, _encryptarray.length); + - returnConvert.tobase64string (Resultarray,0, resultarray.length); the *}
2. Decryption
1 /// <summary>2 3 ///Content Decryption4 5 /// </summary>6 7 /// <param name= "Encryptioncontent" >Encrypted Content</param>8 9 /// <param name= "Strkey" >Key Value</param>Ten One /// <returns></returns> A - Public stringDecipheringcontent (stringEncryptioncontent,stringstrkey) - the { - - byte[] Keyarray =UTF8Encoding.UTF8.GetBytes (strkey); - +RijndaelManaged decipher =Newrijndaelmanaged (); - +Decipher. Key =Keyarray; A atDecipher. Mode =CIPHERMODE.ECB; - -Decipher. Padding =PADDINGMODE.PKCS7; - -ICryptoTransform Ctransform =Decipher. CreateDecryptor (); - in byte[] _encryptarray =convert.frombase64string (encryptioncontent); - to byte[] Resultarray = Ctransform.transformfinalblock (_encryptarray,0, _encryptarray.length); + - returnUTF8Encoding.UTF8.GetString (resultarray); the *}
Unity3d data Addition/decryption