Skip to content

otplib API Documentation / @otplib/core / utils / counterToBytes

Function: counterToBytes() ​

counterToBytes(value): Uint8Array

Defined in: packages/core/src/utils.ts:662

Convert counter to 8-byte big-endian array

Per RFC 4226 Section 5.1, the counter value is represented as an 8-byte big-endian (network byte order) unsigned integer.

Parameters ​

value ​

number | bigint

The counter value to convert

Returns ​

Uint8Array

8-byte big-endian array

See ​

RFC 4226 Section 5.1 - Symbol Descriptions

Released under the MIT License.