Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

10 Commits

Repository files navigation

Bcrypt for C++

Introduction

A c++ wrapper for libxcrypt around bcrypt password hashing

Dependencies

To 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

AltStyle によって変換されたページ (->オリジナル) /