pzduniak / ml_bcrypt

Bcrypt module for MTA:SA

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ml_bcrypt - MTA bcrypt module

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.


Compiling

Windows

premake5.exe vs2015

The project files are available in Build/ then.

Linux

./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

Documentation

bcrypt_digest

string bcrypt_digest(string key, string salt)

Returns the hash.

bcrypt_salt

string bcrypt_salt(int logRounds)

Please visit this link to determine the number of rounds appropriate for your server. Returns the salt.

bcrypt_verify

bool bcrypt_verify(string key, string digest)

Returns whether it is verified. How does it get the salt?

Example

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

About

Bcrypt module for MTA:SA

License:zlib License


Languages

Language:C 65.6%Language:C++ 18.0%Language:Roff 11.2%Language:Assembly 2.9%Language:Makefile 1.4%Language:Lua 0.8%