// Token: 0x06000020 RID: 32 RVA: 0x000043F8 File Offset: 0x000025F8 private static AesCryptoServiceProvider GetProvider(byte[] key) { AesCryptoServiceProvider aesCryptoServiceProvider = new AesCryptoServiceProvider(); aesCryptoServiceProvider.BlockSize = 128; aesCryptoServiceProvider.KeySize = 128; aesCryptoServiceProvider.Mode = CipherMode.ECB; aesCryptoServiceProvider.Padding = PaddingMode.PKCS7; aesCryptoServiceProvider.GenerateIV(); aesCryptoServiceProvider.IV = new byte[16]; byte[] key2 = EncryptedString.GetKey(key, aesCryptoServiceProvider); aesCryptoServiceProvider.Key = key2; return(aesCryptoServiceProvider); }
public static string DecryptString(string base64StringToDecrypt, string passphrase) { string end; using (AesCryptoServiceProvider provider = EncryptedString.GetProvider(Encoding.Default.GetBytes(passphrase))) { byte[] numArray = Convert.FromBase64String(base64StringToDecrypt); ICryptoTransform cryptoTransform = provider.CreateDecryptor(); MemoryStream memoryStream = new MemoryStream(numArray, 0, (int)numArray.Length); CryptoStream cryptoStream = new CryptoStream(memoryStream, cryptoTransform, CryptoStreamMode.Read); end = (new StreamReader(cryptoStream)).ReadToEnd(); } return(end); }
// Token: 0x0600001F RID: 31 RVA: 0x00004388 File Offset: 0x00002588 public static string DecryptString(string base64StringToDecrypt, string passphrase) { string result; using (AesCryptoServiceProvider provider = EncryptedString.GetProvider(Encoding.Default.GetBytes(passphrase))) { byte[] array = Convert.FromBase64String(base64StringToDecrypt); ICryptoTransform transform = provider.CreateDecryptor(); MemoryStream stream = new MemoryStream(array, 0, array.Length); CryptoStream stream2 = new CryptoStream(stream, transform, CryptoStreamMode.Read); result = new StreamReader(stream2).ReadToEnd(); } return(result); }
public static string EncryptString(string plainSourceStringToEncrypt, string passPhrase) { string base64String; using (AesCryptoServiceProvider provider = EncryptedString.GetProvider(Encoding.Default.GetBytes(passPhrase))) { byte[] bytes = Encoding.ASCII.GetBytes(plainSourceStringToEncrypt); ICryptoTransform cryptoTransform = provider.CreateEncryptor(); MemoryStream memoryStream = new MemoryStream(); CryptoStream cryptoStream = new CryptoStream(memoryStream, cryptoTransform, CryptoStreamMode.Write); cryptoStream.Write(bytes, 0, (int)bytes.Length); cryptoStream.FlushFinalBlock(); base64String = Convert.ToBase64String(memoryStream.ToArray()); } return(base64String); }