Go to file
2024-01-17 19:51:43 +03:00
README.md Add README.md 2024-01-17 19:50:29 +03:00
utils.v Add utils.v 2024-01-17 19:51:43 +03:00
V.mod Add V.mod 2024-01-17 19:49:07 +03:00
Ask

V OTP 0.1

votp enables you to add TOTP or HOTP functionaltiies in your code the V programming language.

Twitter URL

Installation

v up
v install OdaiGH.votp

Usage

Time-based one-time password is as follows

>>> import odaigh.votp
>>> totp := new_totp("YOUR_SECRET", 6, "TYPE_OF_DIGEST", INTERVAL_IN_SECONDS) // DIGESTS SUPPORT are {sha1,sha256,sha512}
>>> totp := new_totp("odai alghamdi", 6, "sha512", 30)
>>> generated_otp := totp.generate_totp()
214205
>>> verify_otp := totp.verify(214205) //verify if given otp at the current time is correct
true
>>> verify_otp := totp.verify(123456)
false

HMAC-based one-time password is as follows

>>> import odaigh.votp
>>> totp := new_hotp("YOUR_SECRET", 6, "TYPE_OF_DIGEST") // DIGESTS SUPPORT are {sha1,sha256,sha512}
>>> totp := new_hotp("base32secret3232", 6, "sha512")
>>> generated_otp := hotp.generate_hotp(COUNTER) // COUNTER for your hmac otp
>>> generated_otp := hotp.generate_hotp(0) // COUNTER for your hmac otp
492039
>>> verify_otp := hotp.verify(492039,0) //verify if given otp at the current counter is correct
true
>>> verify_otp := hotp.verify(492039,1)
false

License

V otp is licensed under MIT.

Contributing

Follow the instructions in CONTRIBUTING.md