diff options
author | mvel <mvel@yandex-team.ru> | 2022-02-10 16:45:41 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:41 +0300 |
commit | bd30392c4cc92487950adc375c07adf52da1d592 (patch) | |
tree | e8d1a3f19b7fc890bcef6e4cc5de41f1d88c9ac3 /library/cpp/digest | |
parent | 5d50718e66d9c037dc587a0211110b7d25a66185 (diff) | |
download | ydb-bd30392c4cc92487950adc375c07adf52da1d592.tar.gz |
Restoring authorship annotation for <mvel@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/digest')
-rw-r--r-- | library/cpp/digest/md5/md5.cpp | 14 | ||||
-rw-r--r-- | library/cpp/digest/md5/md5.h | 16 | ||||
-rw-r--r-- | library/cpp/digest/md5/md5_medium_ut.cpp | 6 | ||||
-rw-r--r-- | library/cpp/digest/md5/md5_ut.cpp | 28 | ||||
-rw-r--r-- | library/cpp/digest/old_crc/crc.h | 4 |
5 files changed, 34 insertions, 34 deletions
diff --git a/library/cpp/digest/md5/md5.cpp b/library/cpp/digest/md5/md5.cpp index 24a5b69eef..374f6aeda7 100644 --- a/library/cpp/digest/md5/md5.cpp +++ b/library/cpp/digest/md5/md5.cpp @@ -1,8 +1,8 @@ -#include "md5.h" - +#include "md5.h" + #include <library/cpp/string_utils/base64/base64.h> -#include <util/stream/input.h> +#include <util/stream/input.h> #include <util/stream/file.h> #include <util/string/hex.h> @@ -99,10 +99,10 @@ void MD5::Init() { BufferSize = 0; StreamSize = 0; /* Load magic initialization constants. */ - State[0] = 0x67452301; - State[1] = 0xefcdab89; - State[2] = 0x98badcfe; - State[3] = 0x10325476; + State[0] = 0x67452301; + State[1] = 0xefcdab89; + State[2] = 0x98badcfe; + State[3] = 0x10325476; } /* diff --git a/library/cpp/digest/md5/md5.h b/library/cpp/digest/md5/md5.h index 2c17aa0518..e1b804d128 100644 --- a/library/cpp/digest/md5/md5.h +++ b/library/cpp/digest/md5/md5.h @@ -4,7 +4,7 @@ #include <util/generic/strbuf.h> class IInputStream; - + class MD5 { public: MD5() { @@ -29,12 +29,12 @@ public: void Pad(); ui8* Final(ui8[16]); - // buf must be char[33]; - char* End(char* buf); - - // buf must be char[25]; - char* End_b64(char* buf); - + // buf must be char[33]; + char* End(char* buf); + + // buf must be char[25]; + char* End_b64(char* buf); + // 8-byte xor-based mix ui64 EndHalfMix(); @@ -45,7 +45,7 @@ public: * * Return nullptr / empty string if the file does not exist. */ - static char* File(const char* filename, char* buf); + static char* File(const char* filename, char* buf); static TString File(const TString& filename); static char* Data(const void* data, size_t len, char* buf); diff --git a/library/cpp/digest/md5/md5_medium_ut.cpp b/library/cpp/digest/md5/md5_medium_ut.cpp index a940c5cb66..20067aa62c 100644 --- a/library/cpp/digest/md5/md5_medium_ut.cpp +++ b/library/cpp/digest/md5/md5_medium_ut.cpp @@ -20,6 +20,6 @@ Y_UNIT_TEST_SUITE(TMD5MediumTest) { s.to_lower(); UNIT_ASSERT_VALUES_EQUAL(s, "34a5a7ed4f0221310084e21a1e599659"); - } - } -} + } + } +} diff --git a/library/cpp/digest/md5/md5_ut.cpp b/library/cpp/digest/md5/md5_ut.cpp index 1c3e4ad0a9..d92efc9975 100644 --- a/library/cpp/digest/md5/md5_ut.cpp +++ b/library/cpp/digest/md5/md5_ut.cpp @@ -7,35 +7,35 @@ Y_UNIT_TEST_SUITE(TMD5Test) { Y_UNIT_TEST(TestMD5) { - // echo -n 'qwertyuiopqwertyuiopasdfghjklasdfghjkl' | md5sum + // echo -n 'qwertyuiopqwertyuiopasdfghjklasdfghjkl' | md5sum constexpr const char* b = "qwertyuiopqwertyuiopasdfghjklasdfghjkl"; - MD5 r; - r.Update((const unsigned char*)b, 15); - r.Update((const unsigned char*)b + 15, strlen(b) - 15); + MD5 r; + r.Update((const unsigned char*)b, 15); + r.Update((const unsigned char*)b + 15, strlen(b) - 15); - char rs[33]; + char rs[33]; TString s(r.End(rs)); - s.to_lower(); + s.to_lower(); UNIT_ASSERT_NO_DIFF(s, TStringBuf("3ac00dd696b966fd74deee3c35a59d8f")); TString result = r.Calc(TStringBuf(b)); - result.to_lower(); + result.to_lower(); UNIT_ASSERT_NO_DIFF(result, TStringBuf("3ac00dd696b966fd74deee3c35a59d8f")); - } + } Y_UNIT_TEST(TestFile) { TString s = NUnitTest::RandomString(1000000, 1); const TString tmpFile = "tmp"; - { + { TFixedBufferFileOutput fo(tmpFile); fo.Write(s.data(), s.size()); - } + } - char fileBuf[100]; - char memBuf[100]; + char fileBuf[100]; + char memBuf[100]; TString fileHash = MD5::File(tmpFile.data(), fileBuf); TString memoryHash = MD5::Data((const unsigned char*)s.data(), s.size(), memBuf); @@ -47,7 +47,7 @@ Y_UNIT_TEST_SUITE(TMD5Test) { NFs::Remove(tmpFile); fileHash = MD5::File(tmpFile); UNIT_ASSERT_EQUAL(fileHash.size(), 0); - } + } Y_UNIT_TEST(TestIsMD5) { UNIT_ASSERT_EQUAL(false, MD5::IsMD5(TStringBuf())); @@ -63,4 +63,4 @@ Y_UNIT_TEST_SUITE(TMD5Test) { UNIT_ASSERT_EQUAL(MD5::CalcHalfMix(""), 7203772011789518145ul); UNIT_ASSERT_EQUAL(MD5::CalcHalfMix("qwertyuiopqwertyuiopasdfghjklasdfghjkl"), 11753545595885642730ul); } -} +} diff --git a/library/cpp/digest/old_crc/crc.h b/library/cpp/digest/old_crc/crc.h index 4a3ce6d05e..5ffb93b2fa 100644 --- a/library/cpp/digest/old_crc/crc.h +++ b/library/cpp/digest/old_crc/crc.h @@ -53,9 +53,9 @@ inline ui64 crc64(const void* buf, size_t buflen, ui64 crcinit = CRC64INIT) { const unsigned char* ptr = (const unsigned char*)buf; extern const ui64* crctab64; - while (buflen--) { + while (buflen--) { crcinit = crctab64[((crcinit >> 56) ^ *ptr++)] ^ (crcinit << 8); - } + } return crcinit; } |