Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic terminal-console functionallity #159

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

GiorgosXou
Copy link

@GiorgosXou GiorgosXou commented Feb 25, 2024

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.

>  pyotp --help
usage: pyotp [-h] [--hotp NUMBER] [--hex] [-v] [secret]

positional arguments:
  secret         base32 secret

options:
  -h, --help     show this help message and exit
  --hotp NUMBER  specify HOTP position\number
  --hex          returns a 40-character hex-encoded secret
  -v, --version  show program's version number and exit

Generate a 32-character base32 secret:

> pyotp
BQ5NYTKAEIDXVF24W5HM2BK7K2TTBEKE

... hex-encoded:

> pyotp --hex
FD5FF5943E44373F4062773365EE865C5196D56B

Get TOTP digits:

> pyotp BQ5NYTKAEIDXVF24W5HM2BK7K2TTBEKE
378127

Get HOTP digits

> pyotp BQ5NYTKAEIDXVF24W5HM2BK7K2TTBEKE --hotp 0
398346

peace and love

@peterthomassen
Copy link

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).

@GiorgosXou
Copy link
Author

GiorgosXou commented Feb 26, 2024

@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.

@peterthomassen
Copy link

Another option would be to allow passing the secret in a file, and allow the filename to be /dev/stdin (or - for short).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants