A plugin for generating/verifying 2FA authentication tokens per TOTP for samp/open.mp in Rust. Made using totp-rs.
- 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) orsamp_totp.so
for linux. - Add samp_totp.inc in includes folder.
- Clone the repo
git clone https://github.com/Tiaansu/samp-cron.git
- Install Rust
rustup update stable-i686 --no-self-update && rustup default stable-i686
- Build using
cargo build
cargo build --release
-
output
- the secret will be storedsize
- the maximum sizeoutput
can hold
Returns
- true/false
Example
main() { new output[MAX_TOTP_SECRET_LENGTH]; totp_generate_secret(output, sizeof(output)); }
-
secret
- the output oftotp_generate_secret
.otp
- the OTP (from your authenticator app)
Returns
- true if valid, false if invalid
Example
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"); }