I can't be bothered to do a real solution
This commit is contained in:
@@ -2,6 +2,7 @@ using System;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
public class SensitiveInfo
|
public class SensitiveInfo
|
||||||
{
|
{
|
||||||
@@ -31,20 +32,28 @@ public class SensitiveInfo
|
|||||||
|
|
||||||
public static string Decrypt(string dataB64, string key)
|
public static string Decrypt(string dataB64, string key)
|
||||||
{
|
{
|
||||||
var data = Convert.FromBase64String(dataB64);
|
try
|
||||||
using Aes aes = Aes.Create();
|
{
|
||||||
aes.Key = Encoding.UTF8.GetBytes(key);
|
var data = Convert.FromBase64String(dataB64);
|
||||||
aes.Mode = CipherMode.CBC;
|
using Aes aes = Aes.Create();
|
||||||
aes.Padding = PaddingMode.PKCS7;
|
aes.Key = Encoding.UTF8.GetBytes(key);
|
||||||
|
aes.Mode = CipherMode.CBC;
|
||||||
|
aes.Padding = PaddingMode.PKCS7;
|
||||||
|
|
||||||
byte[] iv = new byte[16];
|
byte[] iv = new byte[16];
|
||||||
Array.Copy(data, 0, iv, 0, iv.Length);
|
Array.Copy(data, 0, iv, 0, iv.Length);
|
||||||
aes.IV = iv;
|
aes.IV = iv;
|
||||||
|
|
||||||
using MemoryStream ms = new(data, iv.Length, data.Length - iv.Length);
|
using MemoryStream ms = new(data, iv.Length, data.Length - iv.Length);
|
||||||
using var cryptoStream = new CryptoStream(ms, aes.CreateDecryptor(), CryptoStreamMode.Read);
|
using var cryptoStream = new CryptoStream(ms, aes.CreateDecryptor(), CryptoStreamMode.Read);
|
||||||
using StreamReader reader = new(cryptoStream);
|
using StreamReader reader = new(cryptoStream);
|
||||||
|
|
||||||
return reader.ReadToEnd();
|
return reader.ReadToEnd();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
Application.Quit();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user