@nowarajs/totp
    Preparing search index...

    Function createCounterBuffer

    • Convert a counter value to an 8-byte big-endian buffer

      Parameters

      • counter: number | bigint

        Counter value as number or bigint

      Returns ArrayBuffer

      ArrayBuffer containing the counter in big-endian format (8 bytes)

      Always uses BigInt internally to support full 64-bit counter values. This fixes potential integer overflow issues when counter exceeds 2^32-1.

      For TOTP, time steps are calculated as Math.floor(Date.now() / 1000 / period). Current time steps are ~57 million, well within 32-bit range, but this ensures correctness for far-future dates and high-precision use cases.