From fedb30bb4322bc68b6644857aa809c7c77cce9ae Mon Sep 17 00:00:00 2001 From: Leonetienne Date: Sun, 22 May 2022 13:54:03 +0200 Subject: [PATCH] Added padding direction option for Util::StringToBitblock --- GCryptLib/include/GCrypt/Util.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/GCryptLib/include/GCrypt/Util.h b/GCryptLib/include/GCrypt/Util.h index 05de131..e900644 100644 --- a/GCryptLib/include/GCrypt/Util.h +++ b/GCryptLib/include/GCrypt/Util.h @@ -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