Bcrypt module for MTA:SA, for your passwords. Just three handy functions: bcrypt_digest
, bcrypt_salt
, and bcrypt_verify
.
bcrypt will be added in the next MTA version as the passwordHash
and passwordVerify
functions.
premake5.exe vs2015
The project files are available in Build/
then.
./premake5 gmake
# Use either of the following commands
make all # Builds all (both debug and release for x86 and x64 - you'll need gcc-multilib then, not recommended - use one of the commands below instead)
make config=release_x86 all # Release build for the x86 platform
make config=release_x64 all # Release build for the x86_64 platform
string bcrypt_digest(string key, string salt)
Returns the hash.
string bcrypt_salt(int logRounds)
Please visit this link to determine the number of rounds appropriate for your server. Returns the salt.
bool bcrypt_verify(string key, string digest)
Returns whether it is verified. How does it get the salt?
Here's some code that explains the use of all these functions, remember that the database functions mentioned in this aren't real functions and are just for this demonstration.
-- Get this information by conventional means
myName = "qaisjp"
myRegisterPassword = "LoLIcon"
-- When registering
mySalt = bcrypt_salt(10000)
hashedPassword = bcrypt_digest(myRegisterPassword, mySalt)
savePasswordInDatabase(myName, hashedPassword)
-- Now I want to login
myLoginPassword = "LoLIcon"
if bcrypt_verify(hashedPasswordFromDatabase, myLoginPassword) then
outputChatBox("Password verified")
end