Skip to content

tomato2718/otp-rpy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

otp-rpy

OTP related function for python written in rust.

Usage

from time import time

from otp_rpy import generate_hotp, generate_totp, validate_hotp, validate_totp

SECRET = "TESTTESTTESTTEST"

# To create TOTP code
totp_code = generate_totp(SECRET, int(time()))
print(totp_code)

# To validate TOTP code
is_valid = validate_totp(totp_code, secret=SECRET, now=int(time()))
print(is_valid)

# To create HOTP code
hotp_code = generate_hotp(SECRET, 1)
print(hotp_code)

# To validate HOTP code
is_valid = validate_hotp(hotp_code, secret=SECRET, count=2, tolerance=2)
print(is_valid)

About

OTP functions for Python, implemented in Rust

Resources

License

Stars

Watchers

Forks

Packages

No packages published