HOTP(RFC 4226) & TOTP(RFC 6238) & Steam Guard TOTP
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
Prerequisites
rustup target add wasm32-unknown-unknown
cargo install --version=0.2.86 wasm-bindgen-cli
pnpm install
node scripts/build.mjs
cd examples/browser
pnpm install
pnpm dev
Here are some related projects that you may find useful:
- totp-wasm-zig: Zig implementation of this project.
- UdonOTPLib: C# implementation for the VRChat game.
Code is distributed under MIT license, feel free to use it in your proprietary projects as well.