1.解密方法己找到。
public class AesGcm
{
private static string ALGORITHM = "AES/GCM/NoPadding";
private static int TAG_LENGTH_BIT = 128;
private static int NONCE_LENGTH_BYTE = 12;
private static string AES_KEY = "qrmmdt198611qrmmdt198611qrmmdt19";
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);
}
}
请问这个方法的3个参数应该如何传值;
在此记录下踩过的坑,解密key 一定弄明白是用 商户级别的key还是服务商级别的key,看各自账户的性质决定。key不对就导致 gcmBlockCipher.DoFinal(plaintext, length); 这一步报错,抛异常
参看解密文档https://wechatpay-api.gitbook.io/wechatpay-api-v3/qian-ming-zhi-nan-1/zheng-shu-he-hui-tiao-bao-wen-jie-mi