●以下代码为AEAD_AES_256_GCM的解密C#示例代码,未经充分测试,仅供参考。
public static string AesGcmDecrypt(string content, string key, string ivs)
{
byte[] bytes = Encoding.UTF8.GetBytes(key);
byte[] bytes2 = Encoding.UTF8.GetBytes(ivs);
byte[] array = Convert.FromBase64String(content);
byte[] bytes3 = Encoding.UTF8.GetBytes("certificate");
GcmBlockCipher gcmBlockCipher = new GcmBlockCipher(new AesEngine());
AeadParameters aeadParameters = new AeadParameters(new KeyParameter(bytes), 128, bytes2, bytes3);
gcmBlockCipher.Init(false, aeadParameters);
byte[] array2 = new byte[gcmBlockCipher.GetOutputSize(array.Length)];
int num = gcmBlockCipher.ProcessBytes(array, 0, array.Length, array2, 0);
gcmBlockCipher.DoFinal(array2, num);
return Encoding.UTF8.GetString(array2);
}
这个好像用不了
ase加密好像有个两个参数的方法。
AseDecypt(string Data,string Key)
用这个