https://github.com/tiaansu/samp-totp
A totp authentication plugin for samp/open.mp in Rust
https://github.com/tiaansu/samp-totp
Last synced: 2 months ago
JSON representation
A totp authentication plugin for samp/open.mp in Rust
- Host: GitHub
- URL: https://github.com/tiaansu/samp-totp
- Owner: Tiaansu
- License: mit
- Created: 2025-01-26T10:18:02.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2025-01-26T10:24:11.000Z (4 months ago)
- Last Synced: 2025-01-26T11:22:41.643Z (4 months ago)
- Language: Rust
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# samp-totp
A plugin for generating/verifying 2FA authentication tokens per TOTP for samp/open.mp in Rust. Made using [totp-rs](https://docs.rs/totp-rs/latest/totp_rs).
## Installation
- Download the suitable binary files from releases for your operating system.
- Add it to your `plugins` folder
- Add `samp_totp` to server.cfg (config.json if you're using open.mp) or `samp_totp.so` for linux.
- Add [samp_totp.inc](./include/samp_totp.inc) in includes folder.## Building
- Clone the repo
```bash
git clone https://github.com/Tiaansu/samp-cron.git
```
- Install Rust
```bash
rustup update stable-i686 --no-self-update && rustup default stable-i686
```
- Build using `cargo build`
```bash
cargo build --release
```## API
* ### totp_generate_secret(const output[], size = sizeof output)
* `output` - the secret will be stored
* `size` - the maximum size `output` can hold**Returns**
* true/false**Example**
```pawn
main()
{
new output[MAX_TOTP_SECRET_LENGTH];
totp_generate_secret(output, sizeof(output));
}
```* ### totp_verify(const secret[], const otp[])
* `secret` - the output of `totp_generate_secret`.
* `otp` - the OTP (from your authenticator app)**Returns**
* true if valid, false if invalid**Example**
```pawn
main()
{
new output[MAX_TOTP_SECRET_LENGTH];
totp_generate_secret(output, sizeof(output));
// replace the 123456 to the actual OTP
printf("OTP is %s", totp_verify(output, "123456") ? "Valid" : "Invalid");
}
```