Signature API

interface Signer {
    sign(privateKey, data): Buffer;
    signByPSS(privateKey, data): Buffer;
}

Methods

Methods

  • Signature. This API is not secure. You are advised to use signByPSS.

    Parameters

    • privateKey: Buffer

      RSA private key

    • data: Buffer

      Signature Data

    Returns Buffer

  • PSS Signature

    Parameters

    • privateKey: Buffer

      RSA private key

    • data: Buffer

      Signature Data

    Returns Buffer

    Example


    import * as crypto from 'crypto';
    import * as buffer from 'buffer';

    let rsakey = crypto.generateKey(1024);

    let data = buffer.from("huawei");
    let sign = crypto.createSign(crypto.Hashs.SHA256);
    let signed = sign.signByPSS(rsakey.privateKey, data);

    console.log(signed.toString(buffer.Encoding.Base64));