EncryptDecrypt.cs 689 B

123456789101112131415161718192021
  1. using UnityEngine;
  2. using System.Collections;
  3. public class EncryptDecrypt
  4. {
  5. public static string GetCompressedAndEncryptedData(byte[] data)
  6. {
  7. byte[] compressedBytes = LZCompression.compress(data, 3);
  8. string compressedString = System.Convert.ToBase64String(compressedBytes);
  9. string encryptedString = AESEncryption.Encrypt(compressedString, "<password>");
  10. return encryptedString;
  11. }
  12. public static byte[] GetDecryptedAndDecompressedData(string encryptedString)
  13. {
  14. string compressedString = AESEncryption.Decrypt(encryptedString, "<password>");
  15. byte[] compressedByte = System.Convert.FromBase64String(compressedString);
  16. return LZCompression.decompress(compressedByte);
  17. }
  18. }