Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding");
String key = "your lv3 api secret";
String associatedData = "xx";
String nonce = "xxxx";
String content = "Base64 str";
byte[] decode = Base64.getDecoder().decode(content);
cipher.init(2, new SecretKeySpec(key.getBytes(), "AES"), new GCMParameterSpec(128, nonce.getBytes()));
if (StringUtils.isNotEmpty(associatedData)) {
cipher.updateAAD(associatedData.getBytes());
}
String str = new String(cipher.doFinal(decode), StandardCharsets.UTF_8);
System.out.println(str);
微信支付AEAD_AES_256_GCM 解密代码片段
于 2023-01-18 14:54:17 首次发布