Skip to content

Latest commit

 

History

History
44 lines (30 loc) · 1.07 KB

README.md

File metadata and controls

44 lines (30 loc) · 1.07 KB

@deanrih/totp-ts

A Time-Based (RFC 6238) and HMAC-Based (RFC 4226) One-Time Password Algorithm Implementation in TypeScript.

Installation

# Bun
bun add @deanrih/totp-ts
# pnpm
pnpm add @deanrih/totp-ts
# npm
npm install @deanrih/totp-ts

Usage

import { generateTotp } from "@deanrih/totp-ts";

const secret = "super_S3cr37-k3y";
const password = generateTotp(secret);

console.log(`Your One-time Password: [${password}]`);
import { generateTotp } from "@deanrih/totp-ts";

const secret = "super_S3cr37-k3y";

console.log(`Your One-time Password: [${generateTotp(secret)}]`);
await Bun.sleep(30 * 1000); // Wait for 30 seconds to see the new code generated
console.log(`Your One-time Password: [${generateTotp(secret)}]`);

Checkout the example folder.

Credits/Reference

IETF RFC Datatracker