Oslo

generateHOTP()

Generates a new HOTP, as defined in RFC 4226.

Definition

function generateHOTP(
	secretKey: ArrayBuffer | TypedArray,
	counter: number,
	digits?: number
): Promise<string>;

Parameters

  • secretKey: HMAC SHA-1 secret key
  • counter
  • digits (default: 6)

Example

import { generateHOTP } from "oslo/otp";
import { HMAC } from "oslo/crypto";

const secret = await new HMAC("SHA-1").generateKey();

let counter = 0;

const otp = await generateHOTP(secret, counter);