Skip to content

Latest commit

 

History

History
177 lines (121 loc) · 5.34 KB

API.md

File metadata and controls

177 lines (121 loc) · 5.34 KB

API说明

class WxCrypto

  • 使用:new WxCrypto(token, aesKey, appID, options)
  • 参数:
参数 说明 类型 可选值 必填 默认
token 消息校验Token,开发者在代替公众号或小程序接收到消息时,用此Token来校验消息 String - -
aesKey 消息加解密Key,在代替公众号或小程序收发消息过程中使用。必须是长度为43位的字符串,只能是字母和数字 String - -
appID 小程序appID String - -
options Options Object - -
  • 示例:
const wxCrypto = new WxCrypto(token, aesKey, appID, options)

function PKCS7Encode

  • 使用:PKCS7Encode(data)
  • 参数:
参数 说明 类型 可选值 必填 默认
data Buffer数据 Buffer - -
  • 示例:
const result = PKCS7Encode(data)
// Buffer

function PKCS7Decode

  • 使用:PKCS7Decode(data)
  • 参数:
参数 说明 类型 可选值 必填 默认
data Buffer数据 Buffer - -
  • 示例:
const result = PKCS7Decode(data)
// Buffer

function aes256Encrypt

  • 使用:aes256Encrypt(algorithm, key, iv, inputEncoding?, outputEncoding?, options?)
  • 参数:
参数 说明 类型 可选值 必填 默认
algorithm algorithm buffer data Buffer[] - -
key AESKey Buffer - -
iv iv Buffer - -
inputEncoding encoding Encoding - -
outputEncoding encoding Encoding - -
options options of createCipheriv CipherGCMOptions - -
  • 示例:
const result = aes256Encrypt(algorithm, key, iv)
// string

function aes256Decrypt

  • 使用:aes256Decrypt(algorithm, key, iv, inputEncoding?, outputEncoding?, options?)
  • 参数:
参数 说明 类型 可选值 必填 默认
algorithm algorithm data String - -
key encodingAESKey Buffer - -
iv iv Buffer - -
inputEncoding encoding Encoding - -
outputEncoding encoding Encoding - -
options options of stream.transform CipherCCMOptions - -
  • 示例:
const result = aes256Decrypt(algorithm, key, iv)
// string

function buildXML buildXMLSync

  • 使用:buildXML(data, options?), buildXMLSync(data, options?, callback?)
  • 参数:
参数 说明 类型 可选值 必填 默认
data 数据 Object - -
options xml生成配置 BuildXMLOptions - -
callback 回调方法 Function - -
  • 示例:
const result = buildXML(data)
// string

function parseXML parseXMLSync

  • 使用:parseXML(data, options?), parseXMLSync(data, options?, callback?)
  • 参数:
参数 说明 类型 可选值 必填 默认
data 数据 convertableToString - -
options xml解析配置 ParserXMLOptions - -
callback 回调方法 Function - -
  • 示例:
const result = parseXML(data)
// string

function sha1

  • 使用:sha1(...data)
  • 参数:
参数 说明 类型 可选值 必填 默认
...data 数据 string[] - -
  • 示例:
const result = sha1(data)
// string