Last active
January 31, 2025 09:44
-
-
Save lalosh/4b975f8ab28dd85e17a684d3152f0c3e to your computer and use it in GitHub Desktop.
TOTP generator in case you lost your phone
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* how to use? | |
* install node.js + npm, copy the code in a clean folder, | |
* run `npm i totp-generator` | |
* run `node main.mjs <OTP-CODE>` | |
* you must have the OTP code from the service provider itself (which you get when you did the Multi-factor setup) | |
*/ | |
import { TOTP } from "totp-generator"; | |
const { otp, expires } = TOTP.generate(process.argv[2]); | |
console.log( | |
`Your OTP is ${otp} and expires in ${Math.abs(new Date().getTime() - expires) / 1000} seconds`, | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment