Skip to content

Instantly share code, notes, and snippets.

@vivekrk1992
Last active March 6, 2018 05:56
Show Gist options
  • Save vivekrk1992/fca8ad2e288fe50c99340ea33e32151d to your computer and use it in GitHub Desktop.
Save vivekrk1992/fca8ad2e288fe50c99340ea33e32151d to your computer and use it in GitHub Desktop.
django otp
activate source
```
pip install django-otp
```
INSTALLED_APPS = (
...
'django_otp',
'django_otp.plugins.otp_totp',
'django_otp.plugins.otp_hotp',
'django_otp.plugins.otp_static',
...
)
MIDDLEWARE = (
...
'django.contrib.messages.middleware.MessageMiddleware',
'django_otp.middleware.OTPMiddleware',
...
)
confirm are you activate your source python
python manage.py migrate
then the result will be like bellow
```
Applying otp_hotp.0001_initial... OK
Applying otp_static.0001_initial... OK
Applying otp_totp.0001_initial... OK
```
from django_otp.oath import hotp
secret_key = b'1234567890123467890'
print(hotp(key=secret_key, counter=1, digits=6)) # this is otp
output:
```
328385
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment