diff --git a/Assets/Scripts/SensitiveInfo.cs b/Assets/Scripts/SensitiveInfo.cs index 0742e65..a5d7245 100644 --- a/Assets/Scripts/SensitiveInfo.cs +++ b/Assets/Scripts/SensitiveInfo.cs @@ -2,6 +2,7 @@ using System; using System.IO; using System.Security.Cryptography; using System.Text; +using UnityEngine; public class SensitiveInfo { @@ -31,20 +32,28 @@ public class SensitiveInfo public static string Decrypt(string dataB64, string key) { - var data = Convert.FromBase64String(dataB64); - using Aes aes = Aes.Create(); - aes.Key = Encoding.UTF8.GetBytes(key); - aes.Mode = CipherMode.CBC; - aes.Padding = PaddingMode.PKCS7; + try + { + var data = Convert.FromBase64String(dataB64); + using Aes aes = Aes.Create(); + aes.Key = Encoding.UTF8.GetBytes(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; + 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); + 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(); + return reader.ReadToEnd(); + } + catch + { + Application.Quit(); + return null; + } } } \ No newline at end of file