Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/OdaiGH/votp
otp module for v, written in v
https://github.com/OdaiGH/votp
2fa hmac hotp module totp v vlang vlang-library vlang-module vlang-package
Last synced: 2 months ago
JSON representation
otp module for v, written in v
- Host: GitHub
- URL: https://github.com/OdaiGH/votp
- Owner: OdaiGH
- License: mit
- Created: 2023-11-15T10:12:02.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2023-11-16T15:03:46.000Z (about 1 year ago)
- Last Synced: 2024-08-04T01:05:57.142Z (6 months ago)
- Topics: 2fa, hmac, hotp, module, totp, v, vlang, vlang-library, vlang-module, vlang-package
- Language: V
- Homepage:
- Size: 13.7 KB
- Stars: 15
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- awesome-v - votp - TOTP and HOTP implementation in v. (Libraries / Utility)
README
# V OTP 0.1
votp enables you to add TOTP or HOTP functionaltiies in your code [the V programming language](https://vlang.io).
[![Twitter URL](https://img.shields.io/twitter/url.svg?label=Follow%20odai_alghamdi&style=social&url=https%3A%2F%2Ftwitter.com%2Fodai_alghamdi)](https://twitter.com/odai_alghamdi)
## Installation
```
v up
v install OdaiGH.votp
```## Usage
Time-based one-time password is as follows```v ignore
>>> 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
```v ignore
>>> 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](https://github.com/OdaiGH/votp/blob/master/CONTRIBUTING.md)