using System.Security.Cryptography;
public static class Program
public static void Main()
string r = "d1a007ea97ee1fe227e4a40b088807115a3ac6012f929f1d85211c8d5ce474896e62ac6cdb04f2db17aa13d63dda65da0955703eb4f778241b782dc821ad6a66eae0e6ae737e0a789b88e87e578fc749af0aee3732e808812fe8b4c86243d21855a3680807ce029fe0438ff3cc38df378b46beaa21246eadd7f6ee6c0eb8d54e";
Console.WriteLine($"Decrypted: \"{dec}\"");
public static byte[] HexStringToByteArray(string s)
byte[] buffer = new byte[s.Length / 2];
for (int i = 0; i < s.Length; i += 2)
buffer[i / 2] = (byte)Convert.ToByte(s.Substring(i, 2), 16);
public static string ByteArrayToHexString(byte[] data)
StringBuilder sb = new StringBuilder(data.Length * 3);
sb.Append(Convert.ToString(b, 16).PadLeft(2, '0'));
public static string Decrypt(string cipher)
string password = "a1503725ba805cc3ff6aa340923ad971cf17e33ef65753332ac8ae0e96a26e21";
byte[] key = HexStringToByteArray(password);
var aesObj = new AesGcm(key);
byte[] encryptedData = HexStringToByteArray(cipher);
int cipherSize = encryptedData.Length - nonceSize - tagSize;
var nonce = encryptedData.Take(nonceSize).ToArray();
var cipherBytes = encryptedData.Skip(nonceSize).Take(cipherSize).ToArray();
var tag = encryptedData.Skip(nonceSize+cipherSize).Take(tagSize).ToArray();
byte[] plainBytes = new byte[cipherSize];
Console.WriteLine(ByteArrayToHexString(nonce));
Console.WriteLine(ByteArrayToHexString(cipherBytes));
Console.WriteLine(ByteArrayToHexString(tag));
aesObj.Decrypt(nonce, cipherBytes, tag, plainBytes);
return Encoding.UTF8.GetString(plainBytes);