Created
December 27, 2023 11:36
-
-
Save anandadake/184a590ed89e8a5dc38390885b3e71c1 to your computer and use it in GitHub Desktop.
Python :: 2 factor authentication
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
| # -*- encoding: utf-8 -*- | |
| """ | |
| Python Application | |
| Author: Anand Adake ([email protected]) | |
| """ | |
| """ | |
| requirements | |
| python -m pip install pyotp | |
| python -m pip install segno | |
| """ | |
| import pyotp | |
| import segno | |
| totp_secret = "JBSWY3DPEHPK3PXP" | |
| username = "anand" | |
| issuer = "google.com" | |
| def gen_totp_qr_code(): | |
| otp_uri = pyotp.TOTP(totp_secret, issuer=issuer).provisioning_uri(name=username) | |
| qrcode = segno.make_qr(otp_uri) | |
| qrcode.save("totp_qr_code.png") | |
| # ---------------------------------------- | |
| # launch | |
| # ---------------------------------------- | |
| if __name__ == "__main__": | |
| gen_totp_qr_code() | |
| otp = input("Enter OTP From Authentication App :") | |
| print(pyotp.TOTP(totp_secret).verify(otp)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment