Skip to content

otplib API Documentation / @otplib/core / utils / bytesToString

Function: bytesToString()

bytesToString(bytes): string

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

Convert bytes to UTF-8 string

Uses TextDecoder for proper UTF-8 handling.

Parameters

bytes

Uint8Array

Uint8Array to convert

Returns

string

UTF-8 string

Example

ts
const str = bytesToString(new Uint8Array([104, 101, 108, 108, 111]));
// str === "hello"

Released under the MIT License.