Open vanishcode opened 8 months ago
参考这位博主的思路:
https://blog.steven53.top/p/%E5%AE%81%E7%9B%BE%E4%BB%A4%E7%89%8Cdkey-token%E8%BD%AC%E6%8D%A2%E4%B8%BA%E6%A0%87%E5%87%86totp/
实现代码:
import base32Encode from 'base32-encode'; import { decode as base64Decode } from 'js-base64'; import qrcodeTerminal from 'qrcode-terminal'; const url = process.argv[2]; const { hash } = new URL(url); const data = hash.slice(1); const { token } = JSON.parse(base64Decode(data)); const { seed, passwordLength, timeStep, serial } = token; const secret = base32Encode( new Uint8Array(Buffer.from(seed, 'hex')), 'RFC4648', ); const googleOtpauthURI = `otpauth://totp/${serial}?secret=${secret}&algorithm=SHA1&digits=${passwordLength}&period=${timeStep}`; qrcodeTerminal.generate(googleOtpauthURI, { small: true });
使用:
同样功能的 App 为什么要装两个 😠
参考这位博主的思路:
https://blog.steven53.top/p/%E5%AE%81%E7%9B%BE%E4%BB%A4%E7%89%8Cdkey-token%E8%BD%AC%E6%8D%A2%E4%B8%BA%E6%A0%87%E5%87%86totp/
实现代码:
使用:
同样功能的 App 为什么要装两个 😠