41 lines
1.2 KiB
C#
41 lines
1.2 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Security.Cryptography;
|
|
using System.Text;
|
|
using UnityEngine;
|
|
|
|
public class OldSavefileEncryption
|
|
{
|
|
public const string BAZOOKA_MANAGER_KEY = "5de0d5798d4eb751e13b668c1fc5297d";
|
|
public const string BAZOOKA_MANAGER_FILE_KEY = "e74af7ba21b8b4edd0e3f1d572d63c67";
|
|
|
|
public static string DecryptRaw(byte[] data)
|
|
{
|
|
if (BAZOOKA_MANAGER_KEY.Trim() == string.Empty)
|
|
{
|
|
Debug.LogError("Failed to decrypt: Encryption/Decryption keys not present");
|
|
return null;
|
|
}
|
|
try
|
|
{
|
|
using Aes aes = Aes.Create();
|
|
aes.Key = Encoding.UTF8.GetBytes(BAZOOKA_MANAGER_KEY);
|
|
aes.Mode = CipherMode.CBC;
|
|
aes.Padding = PaddingMode.PKCS7;
|
|
|
|
byte[] iv = new byte[16];
|
|
Array.Copy(data, 0, iv, 0, iv.Length);
|
|
aes.IV = iv;
|
|
|
|
using MemoryStream ms = new(data, iv.Length, data.Length - iv.Length);
|
|
using var cryptoStream = new CryptoStream(ms, aes.CreateDecryptor(), CryptoStreamMode.Read);
|
|
using StreamReader reader = new(cryptoStream);
|
|
|
|
return reader.ReadToEnd();
|
|
}
|
|
catch
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
} |