Skip to content

A totp authentication plugin for samp/open.mp in Rust

License

Notifications You must be signed in to change notification settings

Tiaansu/samp-totp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

samp-totp

A plugin for generating/verifying 2FA authentication tokens per TOTP for samp/open.mp in Rust. Made using 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 in includes folder.

Building

  • 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

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

    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

    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"); 
    }

About

A totp authentication plugin for samp/open.mp in Rust

Resources

License

Stars

Watchers

Forks

Packages

No packages published