Wrapper class for BCrypt password hashing algorithm.
More...
#include <bcrypt.h>
|
| std::string | hash (const std::string &password, unsigned int rounds=10) |
| | Compute BCrypt hash of a password using random salt. More...
|
| |
| std::string | hash (const std::string &password, std::string salt, unsigned int rounds=10) const |
| | Compute BCrypt hash of a password using static salt. More...
|
| |
| std::string | generateSalt (unsigned int size) |
| | Generate a random salt string of the specified size. More...
|
| |
| std::string | generateSalt (char *bytes, int size) const |
| | Generate a salt string from provided byte array. More...
|
| |
|
| static bool | Verify (const std::string &hash, const std::string &password) |
| | Verifies if the password matches a hash. More...
|
| |
Wrapper class for BCrypt password hashing algorithm.
◆ generateSalt() [1/2]
| std::string BCrypt::generateSalt |
( |
unsigned int |
size | ) |
|
Generate a random salt string of the specified size.
- Parameters
-
| size | The size of the salt to be generated |
- Returns
- Generated salt string
- Exceptions
-
| {BCryptException} | if blowfish algorithm failed to generate the salt |
| {BCryptSaltSizeException} | if size is too small |
◆ generateSalt() [2/2]
| std::string BCrypt::generateSalt |
( |
char * |
bytes, |
|
|
int |
size |
|
) |
| const |
Generate a salt string from provided byte array.
- Parameters
-
| bytes | Byte array from which to generate the salt |
| size | The size of the provided byte arry |
- Returns
- Generated salt string
- Exceptions
-
| {BCryptException} | if blowfish algorithm failed to generate the salt |
| {BCryptSaltSizeException} | if size is too small |
◆ hash() [1/2]
| std::string BCrypt::hash |
( |
const std::string & |
password, |
|
|
unsigned int |
rounds = 10 |
|
) |
| |
Compute BCrypt hash of a password using random salt.
- Parameters
-
| password | The password in plain text to be hashed |
| rounds | Base-2 logarithm of the iteration count for the underlying Blowfish-based hashing algorithm |
- Returns
- Hash string of the provided password
- Exceptions
-
| {BCryptException} | if blowfish algorithm failed to generate the hash |
◆ hash() [2/2]
| std::string BCrypt::hash |
( |
const std::string & |
password, |
|
|
std::string |
salt, |
|
|
unsigned int |
rounds = 10 |
|
) |
| const |
Compute BCrypt hash of a password using static salt.
Try to avoid using this method, but if you must have a static salt, then generate it with generateSalt(int size) method.
- Parameters
-
| password | The password in plain text to be hashed |
| salt | The salt to be used for hashing the password |
| rounds | Base-2 logarithm of the iteration count for the underlying Blowfish-based hashing algorithm |
- Returns
- Hash string of the provided password
- Exceptions
-
| {BCryptException} | if blowfish algorithm failed to generate the hash |
| {BCryptSaltSizeException} | if salt size is too small |
◆ Verify()
| static bool BCrypt::Verify |
( |
const std::string & |
hash, |
|
|
const std::string & |
password |
|
) |
| |
|
static |
Verifies if the password matches a hash.
- Parameters
-
| hash | BCrypt hash of the password |
| password | The password in plain text |
- Returns
- true if password matches the hash
The documentation for this class was generated from the following file:
- C:/CProjects/Libs/CommonLib/include/commonlib/crypto/bcrypt/bcrypt.h