Skip to content

gizmo-ds/totp-wasm-zig

Repository files navigation

totp-wasm-zig

License CI

HOTP(RFC 4226) & TOTP(RFC 6238) & Steam Guard TOTP

Demo

https://totp-wasm-zig.vercel.app

Usage

Deno

import { totp, init, wasm_data } from 'https://deno.land/x/totp_wasm/deno/mod.ts'

await init(wasm_data)
const code = totp('GM4VC2CQN5UGS33ZJJVWYUSFMQ4HOQJW', 1662681600, 6, 30)
console.log(code)
// 473526

Browser

example

Node.js

example

Bun

example

Build

Compiling WebAssembly

Requirements:

# pnpm install
zig build
zig build bind

Runing examples

pnpm install
pnpm test:browser

Related Projects

Here are some related projects that you may find useful:

  • totp-wasm: Rust implementation of this project.
  • UdonOTPLib: C# implementation for the VRChat game.

License

Code is distributed under MIT license, feel free to use it in your proprietary projects as well.