Class default<T>

支付宝加解密nodejs版本

Example

const AlipayCrypto = require('alipay-crypto');
const alipayCrypto = new AlipayCrypto(token, encodingAESKey, appID);

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

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

Type Parameters

Hierarchy

  • default

Constructors

Properties

Methods

Constructors

Properties

defaults: PickPartial<OauthCommonOptions, "sign" | "app_id" | "timestamp"> = ...
options: T

Methods

  • rsa encryption

    Parameters

    • initial: string

      Serialized data

    • Optional privateKey: string

      private key, default: options.privateKey

    Returns string

    result - signature

    Since

    1.0.0

  • Type Parameters

    Parameters

    • initial: T
    • Optional privateKey: string

    Returns string

  • md5 encrypt

    Type Parameters

    • T extends Record<string, unknown> = Record<string, unknown>

    Parameters

    • data: string | T

      Parameters that need to be md5 encrypted can be either string or object

    Returns string

    result - encrypted string

    Since

    1.0.0

  • serializedParams 序列化参数

    Parameters

    • data: SignOptions

      Data to be serialized, Strike out the sign field, and strike out parameters with null values.

    • Optional encrypt: boolean

    Returns string

    result - Serialized data

    Since

    1.0.0

    Example

    const data = {
    app_id: '20135234674',
    method: 'alipay.system.oauth.token',
    sign_type: 'RSA2',
    version: '1.0',
    charset: 'utf-8',
    timestamp: '2023-07-29 14:50:22',
    grant_type: 'authorization_code'
    }

    this.serializedParams(data)
    // initial => 'app_id=20135234674&charset=utf-8&grant_type=authorization_code&method=alipay.system.oauth.token&sign_type=RSA2&timestamp=2023-07-29 14:50:22&version=1.0'
    // encrypted => 'app_id=20135234674&charset=utf-8&grant_type=authorization_code&method=alipay.system.oauth.token&sign_type=RSA2&timestamp=2023-07-29%2014%3A50%3A22&version=1.0'

    See

    https://opendocs.alipay.com/common/02khjm

Generated using TypeDoc