Class WxCrypto

微信消息加解密nodejs版本

Example

const WxCrypto = require('node-wxcrypto');
const wxCrypto = new WxCrypto(token, encodingAESKey, appID);

var [err, encryptedXML] = wx.encrypt(xml, timestamp, nonce);

var [err, decryptedXML] = wx.decrypt(signature, timestamp, nonce, encrypted);

Constructors

Properties

appID: string
iv: Buffer
key: Buffer
options: Options
token: string

Methods

  • decrypt

    Parameters

    • data: string

      encrypt string, eg. oVMc1Y6qP86YfAa.../QGgk503Q68Q==

    • timestamp: string | number

      timestamp

    • nonce: string | number

      nonce

    • options: Options = {}

      options

    Returns Promise<any>

    xml - xmData, eg. { ComponentVerifyTicket: 'xxxx', ..., AppId: 'xxxx' }

  • encrypt Base64Encode(AES256Encrypt[RandomString(16B) + ContentLength(4B) + Content + appID])

    Parameters

    • data: Record<string, unknown>

      xml data String, eg. { ComponentVerifyTicket: 'xxxx', ..., AppId: 'xxxx' }

    • options: Options = {}

      options

    Returns Promise<string>

    encrypt - encrypt string, eg. oVMc1Y6qP86YfAa.../QGgk503Q68Q==

  • mergeXmlOptions

    Parameters

    Returns undefined | ParserOptions

    xml - xmData, eg. { ComponentVerifyTicket: 'xxxx', ..., AppId: 'xxxx' }

Generated using TypeDoc