How to use the rfc4648.base32.parse function in rfc4648

To help you get started, we’ve selected a few rfc4648 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github EdgeApp / edge-core-js / src / util / crypto / hotp.js View on Github external
export function fixOtpKey(secret: string) {
  return base32.stringify(base32.parse(secret, { loose: true }))
}
github EdgeApp / edge-core-js / src / util / crypto / hotp.js View on Github external
export function totp(
  secret: string | void,
  now: number = Date.now() / 1000
): string | void {
  if (secret == null) return
  return hotp(base32.parse(secret, { loose: true }), now / 30, 6)
}