A one-time password generator.
Modern OTPs are generated from a fixed, constant setup key. otp_gen
stores that setup key, encrypting it with a user-defined passcode and decrypting it where necessary.
- The actual OTP is then generated based on the current timestamp (most implementations have 30-second interval timestamps) and the setup key.
Install the required dependencies with:
pip install -r requirements.txt
Generate a setup key with a PIN with:
python add_setupkey.py
This will prompt you for:
- A PIN code to be used to encrypt the setup key.
- Warning: For security reasons,
otp_gen
does not store that PIN, so don't lose it. - You might also want to set up a separate authenticator (e.g. using Google Authenticator) to ensure you can still log in if the encrypted setupkey is corrupted.
- Warning: For security reasons,
- The label to be associated with the setup key (e.g. "Email")
- The actual setup key. This can be obtained either from:
- Scanning the QR code with a regular QR code reader:
- This will give a URI:
otpauth://totp//...?secret=[SETUP KEY]&issuer=...
- The setup key can be manually extracted from that URI.
- This will give a URI:
- Obtaining the setup key directly:
- Scanning the QR code with a regular QR code reader:
Example:
(Note: The actual PIN will not be visible)
python otp_gen.py
This will prompt you for the PIN, and will output all OTPs for the previous, current and next time interval associated with the PIN.