diff options
| author | pkalinnikov <[email protected]> | 2022-02-10 16:50:15 +0300 |
|---|---|---|
| committer | Daniil Cherednik <[email protected]> | 2022-02-10 16:50:15 +0300 |
| commit | 9e33e026829d561d6fd46d72b88c367952e08075 (patch) | |
| tree | 2af190fca83ac522e9a7e29de1daae32582064b4 /util/stream/hex.cpp | |
| parent | ba5325cc01aabb81effc91ff1bdbb461313cbd00 (diff) | |
Restoring authorship annotation for <[email protected]>. Commit 1 of 2.
Diffstat (limited to 'util/stream/hex.cpp')
| -rw-r--r-- | util/stream/hex.cpp | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/util/stream/hex.cpp b/util/stream/hex.cpp index 1c05330504a..6d91cbe1cfc 100644 --- a/util/stream/hex.cpp +++ b/util/stream/hex.cpp @@ -1,30 +1,30 @@ -#include "hex.h" - +#include "hex.h" + #include "output.h" -#include <util/string/hex.h> - +#include <util/string/hex.h> + void HexEncode(const void* in, size_t len, IOutputStream& out) { - static const size_t NUM_OF_BYTES = 32; - char buffer[NUM_OF_BYTES * 2]; - - auto current = static_cast<const char*>(in); - for (size_t take = 0; len; current += take, len -= take) { - take = Min(NUM_OF_BYTES, len); - HexEncode(current, take, buffer); - out.Write(buffer, take * 2); - } -} - + static const size_t NUM_OF_BYTES = 32; + char buffer[NUM_OF_BYTES * 2]; + + auto current = static_cast<const char*>(in); + for (size_t take = 0; len; current += take, len -= take) { + take = Min(NUM_OF_BYTES, len); + HexEncode(current, take, buffer); + out.Write(buffer, take * 2); + } +} + void HexDecode(const void* in, size_t len, IOutputStream& out) { Y_ENSURE(!(len & 1), TStringBuf("Odd buffer length passed to HexDecode")); - - static const size_t NUM_OF_BYTES = 32; - char buffer[NUM_OF_BYTES]; - - auto current = static_cast<const char*>(in); - for (size_t take = 0; len; current += take, len -= take) { - take = Min(NUM_OF_BYTES * 2, len); - HexDecode(current, take, buffer); - out.Write(buffer, take / 2); - } -} + + static const size_t NUM_OF_BYTES = 32; + char buffer[NUM_OF_BYTES]; + + auto current = static_cast<const char*>(in); + for (size_t take = 0; len; current += take, len -= take) { + take = Min(NUM_OF_BYTES * 2, len); + HexDecode(current, take, buffer); + out.Write(buffer, take / 2); + } +} |
