refactor: use HexEncoder's built-in lowercase
All checks were successful
continuous-integration/drone/push Build is passing

remove the custom-defined strtolowerpls from generator
This commit is contained in:
surtur 2021-11-14 22:16:52 +01:00
parent d8adb1af87
commit 2cd8345c4e
Signed by: wanderer
GPG Key ID: 19CE1EC1D9E0486D
2 changed files with 2 additions and 10 deletions

@ -63,18 +63,16 @@ auto Generator::do_sha(const std::string& k_n_s) -> std::string {
digest.erase();
CryptoPP::StringSource foo(k_n_s,true,
new HashFilter(sha2_256,new HexEncoder(new StringSink(digest)))
new HashFilter(sha2_256,new HexEncoder(new StringSink(digest),false))
);
digest = strtolowerpls(digest);
assert(digest.compare("bbc093b9819f87c7fa17f135d95ad07ad830ad4a8e74ff0c609709809bf1f1e0")==0);
cout << digest << endl;
digest.erase();
CryptoPP::StringSource bar(k_n_s,true,
new HashFilter(sha3_256,new HexEncoder(new StringSink(digest)))
new HashFilter(sha3_256,new HexEncoder(new StringSink(digest),false))
);
digest = strtolowerpls(digest);
assert(digest.compare("8eccfbbbc9df48b4272e6237ce45aad8fbe59629b4963c4dcda5716e61bb34e1")==0);
cout << digest << endl;
@ -129,10 +127,6 @@ auto Generator::generate_random_data(uint n) -> std::string {
};
auto Generator::strtolowerpls(std::string &s) -> std::string {
std::transform(s.begin(),s.end(),s.begin(),::tolower);
return s;
}
} // namespace generator
} // namespace fortuna

@ -23,8 +23,6 @@ private:
/* n is the number of random bytes to generate */
auto generate_random_data(uint n) -> std::string;
auto strtolowerpls(std::string &s) -> std::string;
protected:
auto get_state() -> Generator::G_state;