@nowarajs/totp
    Preparing search index...

    Function dynamicTruncation

    • Perform dynamic truncation on HMAC result according to RFC 4226

      Parameters

      • hmacArray: Uint8Array

        HMAC result as byte array (minimum 20 bytes)

      • digits: OtpDigits

        Number of digits in the final code (6 or 8)

      Returns string

      Truncated code as string with leading zeros

      (InternalError) - if HMAC array is too short or digits is invalid