Skip to content

Passwords

imshooter edited this page Nov 29, 2026 · 1 revision

Passwords are hashed and verified on up to four threads of the plugin, apart from the connections, so a login never holds the game thread. Argon2id uses AVX2 when the processor has it.

forward OnPasswordHashed(playerid, const hash[]);
forward OnPasswordChecked(playerid, bool:match);

stock Register(playerid, const password[]) {
    mysql_hash_argon2(password, "OnPasswordHashed", "i", playerid);
}

public OnPasswordHashed(playerid, const hash[]) {
    printf("Store %s", hash);

    return 1;
}

stock Login(playerid, const password[], const hash[]) {
    mysql_verify_password(password, hash, "OnPasswordChecked", "i", playerid);
}

public OnPasswordChecked(playerid, bool:match) {
    if (!match) {
        Kick(playerid);
    }

    return 1;
}

The public takes its values first, then the hash or whether the password matched. A hash fits in an array of MYSQL_HASH_LENGTH cells.

Native Work
mysql_hash_argon2 an Argon2id hash, at the costs of mysql_argon2_costs, 19 MiB and two passes by default
mysql_hash_bcrypt a $2b$ bcrypt hash, at the cost of mysql_bcrypt_cost, 12 by default
mysql_verify_password checks a password against an Argon2 or bcrypt hash from any library

Home

Guides

Reference

Functions

Connections
Queries
Cache
JSON cells
ORM
Queries built in pieces
Prepared statements
Batches
Transactions
Passwords
Callbacks

Clone this wiki locally