Created
January 1, 2025 08:18
-
-
Save iamazeem/2daf06dc4c2ae91e010e60200c0e6e76 to your computer and use it in GitHub Desktop.
otplib-demo (TOTP)
This file contains hidden or 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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>otplib demo</title> | |
| <script src="https://unpkg.com/@otplib/preset-browser@^12.0.0/buffer.js"></script> | |
| <script src="https://unpkg.com/@otplib/preset-browser@^12.0.0/index.js"></script> | |
| <script type="text/javascript"> | |
| const authenticator = window.otplib.authenticator; | |
| authenticator.options = { window: 1 }; | |
| const secret = authenticator.generateSecret(); | |
| const token = authenticator.generate(secret); | |
| const verify = authenticator.verify({ token, secret }); | |
| console.log(secret, token, verify); | |
| </script> | |
| </head> | |
| <body> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment