Skip to content

otplib API Documentation / @otplib/plugin-base32-scure / ScureBase32Plugin

Class: ScureBase32Plugin ​

Defined in: index.ts:28

Scure Base32 plugin

This implementation uses @scure/base for Base32 encoding/decoding. @scure/base is a modern, audited cryptography library with zero dependencies.

Example ​

ts
import { ScureBase32Plugin } from '@otplib/plugin-base32-scure';

const plugin = new ScureBase32Plugin();
const encoded = plugin.encode(data);
const decoded = plugin.decode(encoded);

Implements ​

Constructors ​

Constructor ​

new ScureBase32Plugin(): ScureBase32Plugin

Returns ​

ScureBase32Plugin

Properties ​

name ​

readonly name: "scure" = "scure"

Defined in: index.ts:29

The name of the base32 plugin (e.g., 'native', 'ts')

Implementation of ​

Base32Plugin.name

Methods ​

decode() ​

decode(str): Uint8Array

Defined in: index.ts:52

Decode Base32 string to binary data

Parameters ​

str ​

string

Base32 string to decode

Returns ​

Uint8Array

Decoded Uint8Array

Throws ​

If string contains invalid characters

Implementation of ​

Base32Plugin.decode


encode() ​

encode(data, options?): string

Defined in: index.ts:38

Encode binary data to Base32 string

Parameters ​

data ​

Uint8Array

Uint8Array to encode

options? ​

Base32EncodeOptions = {}

Encoding options

Returns ​

string

Base32 encoded string

Implementation of ​

Base32Plugin.encode

Released under the MIT License.