22 December, 2021
2FA stands for two factor authentication. It adds an extra layer of security other than password. The user must enter a 2FA code along with password in order to sign in. 2FA codes can be generated in two ways, time based codes and counter based codes.
| Time based codes | Counter based codes | | :--------------------------------------------------- | :----------------------------------------------------------- | | Time based codes changes depending on time. π | Counter based codes change depending on number of successful sign-in(s). βοΈ | | No need of adding counter every time in client side. | After every successful login, counter must be increased by one in server side as well as client side. |
pip install onetimepass
).For both time based codes and counter based code, a secret string is securely shared with the authenticator app while setting up 2FA. All codes are generated based on this secret string. This string is not case sensitive.
Let us now, write a simple Python script to understand how time based 2FA works!
Here is a complete Python script to understand how counter based 2FA works!
Thank you! Leave a comment and a like if you find this article useful :-)
Copyright Β© 2022 Jothin Kumar