LuaJIT FFI binding for OpenBSD bcrypt (only usable on OpenBSD)
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

A thin Lua wrapper around the OpenBSD implementation of bcrypt. Note that it will NOT run on other operating systems.


OpenBSD, LuaJIT (the one bundled with OpenResty will do).


local bcrypt = require("bcrypt")

-- generate a salt and pass it to digest
local salt = bcrypt.salt(5)
local digest = bcrypt.digest("password", salt)

assert(bcrypt.verify("password", digest))

-- pass number of rounds for salt generation instead of salt
local digest = bcrypt.digest("password", 5)

assert(bcrypt.verify("password", digest))

-- pass only key without salt, salt will automatically be generated in 5 rounds and used
local digest = bcrypt.digest("password")

assert(bcrypt.verify("password", digest))