Options
All
  • Public
  • Public/Protected
  • All
Menu

Module @stablelib/hmac

Index

Classes

Functions

Functions

  • equal(a: Uint8Array, b: Uint8Array): boolean
  • Returns true if two HMAC digests are equal. Uses constant-time comparison to avoid leaking timing information.

    Example:

    const receivedDigest = ... const realDigest = hmac(SHA256, key, data); if (!equal(receivedDigest, realDigest)) { throw new Error("Authentication error"); }

    Parameters

    • a: Uint8Array
    • b: Uint8Array

    Returns boolean

  • hmac(hash: new () => Hash, key: Uint8Array, data: Uint8Array): Uint8Array
  • Returns HMAC using the given hash constructor for the key over data.

    Parameters

    • hash: new () => Hash
        • new (): Hash
        • Returns Hash

    • key: Uint8Array
    • data: Uint8Array

    Returns Uint8Array

Generated using TypeDoc