Open GiorgosXou opened 9 months ago
Secret should be read from stdin (not passed as an argument) as it can otherwise be observed by other users on the same machine (by inspecting the process list).
@peterthomassen how about:
> pyotp -h
PyOTP v.2.9.0 usage:
pyotp - Generate a 32-character base32 secret
pyotph - Generate a hex-encoded base32 secret
pytotp - Return TOTP digits from base32 secret
pyhotp - Return HOTP digits from base32 secret
> pyotp
C5B7WOU3VTI6CHGQZCYQX7VPFT2W257E
> pyotph
74524F37F12534CA383162CBB56A433776CAC65B
> pytotp
Enter base32 secret: C5B7WOU3VTI6CHGQZCYQX7VPFT2W257E
983511
> pyhotp
Enter base32 secret: C5B7WOU3VTI6CHGQZCYQX7VPFT2W257E
Enter number: 23
983754
Simple, yet intuitive.
Another option would be to allow passing the secret in a file, and allow the filename to be /dev/stdin
(or -
for short).
This might be handy for some people... eg. today i had to use your library for pip two-factor authentication... But feel free to change anything or even drop this pull-request if you think otherwise.
Generate a 32-character base32 secret:
... hex-encoded:
Get TOTP digits:
Get HOTP digits
peace and love