Botan 3.4.0
Crypto and TLS for C&
bcrypt.h
Go to the documentation of this file.
1/*
2* Bcrypt Password Hashing
3* (C) 2011 Jack Lloyd
4*
5* Botan is released under the Simplified BSD License (see license.txt)
6*/
7
8#ifndef BOTAN_BCRYPT_H_
9#define BOTAN_BCRYPT_H_
10
11#include <botan/types.h>
12#include <string>
13
14namespace Botan {
15
16class RandomNumberGenerator;
17
18/**
19* Create a password hash using Bcrypt
20*
21* @warning The password is truncated at at most 72 characters; characters after
22* that do not have any effect on the resulting hash. To support longer
23* passwords, consider pre-hashing the password, for example by using
24* the hex encoding of SHA-256 of the password as the input to bcrypt.
25*
26* @param password the password.
27* @param rng a random number generator
28* @param work_factor how much work to do to slow down guessing attacks
29* @param version which version to emit (may be 'a', 'b', or 'y' all of which
30* have identical behavior in this implementation).
31*
32* @see https://www.usenix.org/events/usenix99/provos/provos_html/
33*/
34std::string BOTAN_PUBLIC_API(2, 0) generate_bcrypt(std::string_view password,
35 RandomNumberGenerator& rng,
36 uint16_t work_factor = 12,
37 char version = 'a');
38
39/**
40* Check a previously created password hash
41* @param password the password to check against
42* @param hash the stored hash to check against
43*/
44bool BOTAN_PUBLIC_API(2, 0) check_bcrypt(std::string_view password, std::string_view hash);
45
46} // namespace Botan
47
48#endif
#define BOTAN_PUBLIC_API(maj, min)
Definition compiler.h:31
std::string generate_bcrypt(std::string_view pass, RandomNumberGenerator &rng, uint16_t work_factor, char version)
Definition bcrypt.cpp:144
bool check_bcrypt(std::string_view pass, std::string_view hash)
Definition bcrypt.cpp:159