A argon2 plugin for samp in Rust.
- Download suitable binary files from releases for your operating system
- Add it your
plugins
folder - Add
samp_argon2.dll
(for windows) orsamp_argon2.so
(for linux) to server.cfg - Add samp_argon2.inc in includes folder
-
argon2_hash(playerid, const callback[], const pass[], const salt[], variant, mem_cost, time_cost, lanes, hash_length, const args[] = "", {Float, _}:...)
playerid
- id of the playercallback[]
- callback to execute after hashingpass[]
- string to hashsalt[]
- string to saltvariant
- set variantmem_cost
- set mem costtime_cost
- set time costlanes
- set laneshash_length
- set hash lengthargs[]
- custom arguments
Example
main() { argon2_hash(0, "OnPasswordHash", "password", "somesalt", VARIANT_ARGON2I, 4096, 3, 1, 32); } forward OnPasswordHash(playerid); public OnPasswordHash(playerid) { //hashing completed }
-
hash[]
- string to store hashed datasize
- max size of hash string
Example
main() { argon2_hash(0, "OnPasswordHash", "password", "somesalt", VARIANT_ARGON2I, 4096, 3, 1, 32); } forward OnPasswordHash(playerid); public OnPasswordHash(playerid) { new hash[85]; argon2_get_hash(hash); printf("Hash: %s", hash); }
-
argon2_verify(playerid, const callback[], const pass[], const hash[], const args[] = "", {Float, _}:...)
playerid
- id of the playercallback[]
- callback to execute after hashingpass[]
- text to compare with hashhash[]
- hash to compare with textargs[]
- custom arguments
Example
main() { argon2_hash(0, "OnPasswordHash", "password", "somesalt", VARIANT_ARGON2I, 4096, 3, 1, 32); } forward OnPasswordHash(playerid); public OnPasswordHash(playerid) { new hash[85]; argon2_get_hash(hash); argon2_verify(playerid, "OnPasswordVerify", "password", hash); } forward OnPasswordVerify(playerid, bool:success); public OnPasswordVerify(playerid, bool:success) { //success denotes verifying was successful or not if(success) { //verfied } else { //hash doesn't match with text } }