using System.Security.Cryptography;
public static void Main()
string finalOutput = DecryptAES();
Console.WriteLine(finalOutput);
public static string DecryptAES()
string passphrase = "this-is-a-test-passphrase";
string inputData = "94b681ef29d9a6d7-e6fa36c4c00977de1745fc63-a1ad0481bdbeeaa02c013a2dce82520ddd762355e18f1e2f20c0ea9d001ece24e9b8216ed4b9c6a06e1ef34c953f80";
string[] arr = inputData.Split('-');
byte[] salt = Convert.FromHexString(arr[0]);
byte[] iv = Convert.FromHexString(arr[1]);
byte[] data = Convert.FromHexString(arr[2]);
byte[] key = GetPbkdf2Bytes(passphrase, salt, 1000, 32);
return AESDecryption(data, key, iv);
public static string AESDecryption(byte[] data, byte[] key, byte[] iv)
AesCryptoServiceProvider AEScryptoProvider = new AesCryptoServiceProvider();
AEScryptoProvider.BlockSize = 128;
AEScryptoProvider.KeySize = 256;
AEScryptoProvider.Key = key;
AEScryptoProvider.IV = iv;
AEScryptoProvider.Mode = CipherMode.CBC;
AEScryptoProvider.Padding = PaddingMode.PKCS7;
byte[] txtByteData = data;
ICryptoTransform trnsfrm = AEScryptoProvider.CreateDecryptor();
byte[] result = trnsfrm.TransformFinalBlock(txtByteData, 0, txtByteData.Length);
return ASCIIEncoding.ASCII.GetString(result);
public static byte[] StringToByteArray(string hex) {
return Enumerable.Range(0, hex.Length)
.Select(x => Convert.ToByte(hex.Substring(x, 2), 16))
private static byte[] GetPbkdf2Bytes(string password, byte[] salt, int iterations, int outputBytes)
var pbkdf2 = new Rfc2898DeriveBytes(password, salt);
pbkdf2.IterationCount = iterations;
return pbkdf2.GetBytes(outputBytes);