lassir/bcrypt-samp
An implementation of the bcrypt hashing algorithm for SA-MP
Installer avec sampctl
sampctl package install lassir/bcrypt-samp
Lance ceci dans le dossier de ton projet. sampctl télécharge le paquet et ce dont il dépend.
Ajoute ses fichiers include, avec les bibliothèques dont il dépend, au compilateur Pawn de ton navigateur, prêts à être inclus dans un script.
Utilisé par 6 paquets
README.md
Bcrypt for SA-MP
An implementation of bcrypt password hashing library for Pawn, written in C/C++.
Benefits of bcrypt
- All passwords are automatically salted
- Bcrypt is slow, which makes offline bruteforce attacks less efficient
- The work factor can be increased as the computers become more powerful
Functions
bcrypt_hash(const key[], cost = 12, const callback_name[], const callback_format[] = "", {Float, _}:...);bcrypt_check(const password[], const hash[], const callback_name[], const callback_format[] = "", {Float, _}:...);bcrypt_get_hash(dest[]);bcrypt_is_equal();bcrypt_needs_rehash(const hash[], cost);bcrypt_find_cost(time_target = 250);bcrypt_set_thread_limit(value);bcrypt_debug(BCRYPT_DEBUG_LEVEL:level = BCRYPT_LOG_ERROR);
See the wiki for detailed usage.
Installation
Linux
- Copy
bcrypt-samp.soto thepluginsfolder - Add
plugins bcrypt-samp.soto server.cfg - Copy
bcrypt.incto the compiler's include directory (pawno/includeby default) - Add
#include <bcrypt>to your gamemode or filterscript
Windows
- Copy
bcrypt-samp.dllto thepluginsfolder - Add
plugins bcrypt-sampto server.cfg - Copy
bcrypt.incto the compiler's include directory (pawno/includeby default) - Add
#include <bcrypt>to your gamemode or filterscript
Usage
Call function
bcrypt_hashwhen you would like to hash user input (e.g. on registration, or when updating the work factor). Once the hash is calculated, the callback defined in the parameters will be called, and the hash can be acquired usingbcrypt_get_hashfunctionCall function
bcrypt_checkwhen you would like to verify whether or not user input matches a given hash (e.g. on login). Once the verification is done, the callback defined in the parameters will be called, and the result can be acquired usingbcrypt_is_equalfunctionYou can use
bcrypt_needs_rehashto check whether or not the hash needs to be updatedIf you would like to override the default number of threads used, you may use function
bcrypt_set_thread_limit. In most cases, however, the default value is adequate
Example
#include <a_samp>
#include <bcrypt>
#define BCRYPT_COST 12
forward OnPasswordHashed(playerid);
forward OnPasswordChecked(playerid);
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid)
{
case DIALOG_REGISTRATION:
{
bcrypt_hash(inputtext, BCRYPT_COST, "OnPasswordHashed", "d", playerid);
}
case DIALOG_LOGIN:
{
// Variable hash is expected to contain the hash loaded from the database
bcrypt_check(inputtext, hash, "OnPasswordChecked", "d", playerid);
}
}
return 1;
}
public OnPasswordHashed(playerid)
{
new hash[BCRYPT_HASH_LENGTH];
bcrypt_get_hash(hash);
printf("Password hashed for player %d: %s", playerid, hash);
return 1;
}
public OnPasswordChecked(playerid)
{
new bool:match = bcrypt_is_equal();
printf("Password checked for %d: %s", playerid, (match) ? ("Match") : ("No match"));
return 1;
}
Cette page est construite à partir de ce que GitHub publie sur le dépôt. samp.directory n’héberge pas le code. Signaler un problème avec cette fiche