22 #include <boost/random.hpp>
23 #include <boost/generator_iterator.hpp>
34 std::string generate_salt(std::size_t len)
36 boost::mt19937 mt(std::time(0));
37 auto salt = std::string(len,
'0');
38 boost::uniform_int<> from_str(0, 63);
39 boost::variate_generator< boost::mt19937, boost::uniform_int<>> get_char(mt, from_str);
41 for(std::size_t
i = 0;
i < len;
i++) {
50 bool verify_passphrase(
const std::string& passphrase,
const std::string& salt,
const std::string& hash)
55 std::pair<std::string, std::string>
generate_hash(
const std::string& passphrase)
57 const auto& salt = generate_salt(16);
campaignd authentication API.
virtual std::string base64_digest() const override
std::pair< std::string, std::string > generate_hash(const std::string &passphrase)
Generates a salted hash from the specified passphrase.
bool verify_passphrase(const std::string &passphrase, const std::string &salt, const std::string &hash)
Verifies the specified plain text passphrase against a salted hash.
std::string encode(utils::byte_string_view bytes)