Added padding direction option for Util::StringToBitblock

This commit is contained in:
Leonetienne 2022-05-22 13:54:03 +02:00
parent 9fdc642bd6
commit fedb30bb43
No known key found for this signature in database
GPG Key ID: C33879CD92E9708C

View File

@ -72,7 +72,9 @@ namespace Leonetienne::GCrypt {
}
//! Will convert a string to a fixed-size data block
inline Block StringToBitblock(const std::string& s) {
//! @s: The string to pad
//! padLeft: should padding be added to the left? If not, to the right.
inline Block StringToBitblock(const std::string& s, bool padLeft = true) {
std::stringstream ss;
for (std::size_t i = 0; i < s.size(); i++) {
@ -80,7 +82,7 @@ namespace Leonetienne::GCrypt {
}
// Pad rest with zeores
return Block(PadStringToLength(ss.str(), BLOCK_SIZE, '0', false));
return Block(PadStringToLength(ss.str(), BLOCK_SIZE, '0', padLeft));
}
//! Will convert a string to a flexible data block