Installer avec sampctl
sampctl package install Se8870/pp-bcrypt
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.
Dépend de 3 paquets
- sampctl/samp-stdlibpas dans cet annuaire
- illidans4/pawnpluspas dans cet annuaire
- Sreyas-Sreelal/samp-bcrypt★ 84
README.md
PawnPlus BCrypt
PawnPlus BCrypt is a library to make hashing and checking more easy with a help of Task & Await from PawnPlus.
This implementations originally took from Mergevos, but his version doesn't support SyS Bcrypt. Since i don't want to break his work, i decided to make this repo to distinguish between his version and mine.
Installation
Simply install to your project:
sampctl package install Kirima2nd/pp-bcrypt
Include in your code after PawnPlus.inc and BCrypt include, then you can begin using the library:
#include <PawnPlus>
#include <samp_bcrypt>
#include <pp-bcrypt>
Function Lists
/*
Hashing
- returns string hash with BCRYPT_HASH_LENGTH size
- returns Dynamic String
*/
stock Task:BCrypt_AsyncHash(const input[], cost = BCRYPT_COST);
stock Task:BCrypt_AsyncHashStr(ConstStringTag:input, cost = BCRYPT_COST);
/*
Verifying
- Returns integer/number (success can be 0 and 1)
*/
stock Task:BCrypt_AsyncVerify(const input[], const hash[]);
stock Task:BCrypt_AsyncVerifyStr(ConstStringTag:input, ConstStringTag:hash);
Usage
Normal string usage:
#include <PawnPlus>
#include <samp_bcrypt>
#include <pp-bcrypt>
main()
{
new x_result[BCRYPT_HASH_LENGTH];
await_str(x_result) BCrypt_AsyncHash("Hello World!");
new ret = await BCrypt_AsyncVerify("Hello World!", x_result);
printf("Result naked: %s", x_result);
printf("Result same?: %s", ret ? "Yes" : "No");
}
Dynamic String usage:
main()
{
new String:hash = await_str_s BCrypt_AsyncHashStr(str_new_static("Helo World!"), 12);
pawn_guard(hash);
new ret = await BCrypt_AsyncVerifyStr(str_new_static("Helo World!"), hash);
new hash_str[BCRYPT_HASH_LENGTH];
str_get(hash, hash_str);
printf("Result naked: %s", hash_str);
printf("Result same?: %s", ret ? "Yes" : "No");
}
In Dynamic String usage, using pawn_guard is required for making sure that the hash will be destroyed at the end of main function. Without this the hash text can be destroyed when calling BCrypt_AsyncVerifyStr. But if you're already using str_acquire and decided to make the Dynamic String to be accessed globally, then no need to use pawn_guard.
Testing
To test, simply run the package:
sampctl package run
Credits
- Mergevos - async-bcrypt (It give me inspiration to make this one)
- Grabber - pp-mysql (the pp logic basically from his include)
- IllidanS4 - PawnPlus
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