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

Appearance settings

hilch/Bcrypt.cpp

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bcrypt.cpp

A C++ wrapper around bcrypt (origin: Open BSD) password hashing

How to use

Here an example how to use this wrapper class

#include "bcrypt.h"
#include <iostream>
#include <string>


int main()
{

    std::string password = "top_secret";

    std::string hash = bcrypt::generateHash(password);

    std::cout << "Hash: " << hash << std::endl;

    std::cout << "\"" << password << "\" : " << bcrypt::validatePassword(password,hash) << std::endl;
    std::cout << "\"wrong\" : " << bcrypt::validatePassword("wrong",hash) << std::endl;

    return 0;
}

output:

Hash: $2b$10$9ngimRxnytdaWoCd4NKPneEb/9dW24/B830XpS8TbExVeGKbukYbG
"top_secret" : 1
"wrong" : 0

You can check the hash online at https://bcrypt-generator.com

Former version used Open BSD as origin. Since the hash output was not fully compatible to common web services we now use source from node.bcrypt.

But also the web services might differ each other, so just use the hashes generated by this library internally in your application.

About

A c++ wrapper around bcrypt password hashing

Resources

License

Stars

96 stars

Watchers

8 watching

Forks

Packages

 
 
 

Contributors

Morty Proxy This is a proxified and sanitized view of the page, visit original site.