Skip to content

Commit

Permalink
use AesGcm class directly
Browse files Browse the repository at this point in the history
  • Loading branch information
TheNorthMemory committed Apr 8, 2021
1 parent 3628e5a commit 02ba836
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -915,11 +915,11 @@ console.info(params)
## 常见问题
Q: APIv3消息通知,`AesGCM`加密字段,应该如何解密?
Q: APIv3消息通知,`AES-256-GCM`加密字段,应该如何解密?
> 官方文档有介绍,APIv3平台证书及消息通知关键信息均使用`AesGcm`加解密,依赖`APIv3密钥`,商户侧解密可参考`bin/cli/cert.js`证书下载工具,例如:
> ```js
> Aes.decrypt(nonce, secret, ciphertext, aad);
> AesGcm.decrypt(nonce, secret, ciphertext, aad);
> ```
Q: 敏感信息或者幂等操作要求额外头信息上送时,应该如何构建请求参数?
Expand Down
4 changes: 2 additions & 2 deletions bin/cli/cert.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const { readFileSync, writeFileSync } = require('fs');
const { join } = require('path');

const axios = require('axios');
const { default: interceptor, Aes } = require('../..');
const { default: interceptor, Aes: { AesGcm } } = require('../..');

module.exports = {
command: 'crt',
Expand Down Expand Up @@ -66,7 +66,7 @@ module.exports = {
(response.data.data || []).forEach(({
serial_no: serialNo, encrypt_certificate: { nonce, associated_data: aad, ciphertext },
}) => {
Object.assign(certs, { [serialNo]: Aes.decrypt(nonce, secret, ciphertext, aad) });
Object.assign(certs, { [serialNo]: AesGcm.decrypt(nonce, secret, ciphertext, aad) });
});

return response;
Expand Down

0 comments on commit 02ba836

Please sign in to comment.