• Creates an HMAC object.

    Parameters

    • hash: Hashs

      Indicates the hash algorithm name. Note: MD5 and SHA1 are insecure hash algorithms.

    • key: Buffer

      hash key, Note: Do not write sensitive information in plaintext in the code.

    Returns Hmac

    Example


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

    let hmac = crypto.createHmac(crypto.Hashs.SHA256, buffer.from('****************'));

    console.log(hmac.sum(buffer.from('************')).toString(buffer.Encoding.Base64));