Skip to content

Latest commit

 

History

History
47 lines (30 loc) · 1.29 KB

File metadata and controls

47 lines (30 loc) · 1.29 KB

Bcryptcpp

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

Made compatible with the Qt Framework. For more information go to Qt Documentation

How to use

Here an example how to use this wrapper class

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


int main()
{

    std::string password = "top_secret";

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

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

    std::cout << "\"" << password << "\" : " << bcryptcpp::validatePassword(password,hash) << std::endl;
    std::cout << "\"wrong\" : " << bcryptcpp::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.