Skip to content
API Documentation
BastionGuard™
HibpPasswordProvider.cpp File Reference

Go to the source code of this file.

Functions

static std::string sha1HexUpper (const std::string &input)
static void rtrim_crlf (std::string &s)

Function Documentation

◆ rtrim_crlf()

void rtrim_crlf ( std::string & s)
inlinestatic

Definition at line 47 of file HibpPasswordProvider.cpp.

48{
49 while (!s.empty() && (s.back() == '\r' || s.back() == '\n'))
50 s.pop_back();
51}

References rtrim_crlf().

Referenced by HibpPasswordProvider::checkPassword(), and rtrim_crlf().

◆ sha1HexUpper()

std::string sha1HexUpper ( const std::string & input)
static

Definition at line 30 of file HibpPasswordProvider.cpp.

31{
32 unsigned char hash[SHA_DIGEST_LENGTH];
33 SHA1(reinterpret_cast<const unsigned char*>(input.data()),
34 input.size(),
35 hash);
36
37 std::ostringstream oss;
38 oss << std::uppercase << std::hex << std::setfill('0');
39
40 for (int i = 0; i < SHA_DIGEST_LENGTH; ++i) {
41 oss << std::setw(2) << static_cast<unsigned int>(hash[i]);
42 }
43
44 return oss.str();
45}

References sha1HexUpper().

Referenced by HibpPasswordProvider::checkPassword(), and sha1HexUpper().