Skip to content

A c++ wrapper for libxcrypt around bcrypt password hashing

License

Notifications You must be signed in to change notification settings

xiadnoring/bcryptcpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bcrypt for C++

Introduction

A c++ wrapper for libxcrypt around bcrypt password hashing

Dependencies

For compile this library if you use c++ std less than 20, you need to install below libraries:

  • fmt 11.0.2 or greater

For Arch Linux

pacman -S fmt

or

paru -S fmt

For Ubuntu

apt-get install libfmt-dev

Build

With Conan

cmake ... -DWITH_CONAN=ON

or

conan create . --build=missing
  • CMake package name: bcryptcpp
  • CMake target name: bcryptcpp::bcryptcpp

A simple use case using the CMake file name and the global target:

find_package(bcryptcpp REQUIRED)
# ...
target_link_libraries(YOUR_TARGET bcryptcpp::bcryptcpp)

For an example of use, see the ./test folder

Example

#include <bcryptcpp/bcryptcpp.hpp>
...
std::string passwd = "12345";
std::string hash = bcrypt::hash (passwd, bcrypt::gensalt (12));
...
bool valid = bcrypt::compare (hash, passwd);
#include <iostream>
...
try 
{
    // invalid hash
    valid = bcrypt::compare("12345", passwd);
}
catch (const bcrypt::exception::compare &e) 
{
    std::cerr << e.what() << "\n";
}

About

A c++ wrapper for libxcrypt around bcrypt password hashing

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published