A free, time-based OTP generator(client). Based on RFC-6238 spec.
-
Requires python3.
brew install python3
-
Setup virtual environment
python3 -m venv env
-
Activate virtual environment
source env/bin/activate
-
Run the app locally
python app.py
-
Deploy it in a cloud function or run the flask server locally :)
-
If you want to execute this as a regular python script to try it out
python3 local.py <<< base32encodedString
orpython3 local.py <<< hexEncodedString
If you want to refactor the code as a HOTP generator, replace the get_number_of_time_steps
with your counter
and that should do the trick.
Sample input:
http://127.0.0.1:5000/generate?code=1d319930bdb2ea7d580080f637cd9e53d6ef1767&digits=6
code
is the secret key for the SHA-1 hash(hex encoded) OR use a base32 secret key.
digits
is number of digits you want the algorithm to return (max 8).
alg
is the type of SHA algorithm to be used based on the code provided. SHA-1, SHA-256, SHA-512
supported.
If you're a fan of the curl command:
curl -X GET "http://127.0.0.1:5000/generate?code=base32encodedString&digits=6&alg=sha1"
To verify that the generator is working as expected
- Scan the QR code from website https://www.xanxys.net/totp/ on an authenticator app
- Use the link above in sample and hit the server (running on your machine). The site uses SHA-1 codes.
- Response from the Flask app and your authenticator app should match.
Here is a sample output: