diff options
author | romanoved <romanoved@yandex-team.ru> | 2022-02-10 16:45:56 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:56 +0300 |
commit | 90132a2ca55bba6a3adaf9aff8aed49128867d84 (patch) | |
tree | 31b87b38cf64c8a06dc9225c2627ca5ec2b1aae1 /library/cpp/digest | |
parent | 62a805381e41500fbc7914c37c71ab040a098f4e (diff) | |
download | ydb-90132a2ca55bba6a3adaf9aff8aed49128867d84.tar.gz |
Restoring authorship annotation for <romanoved@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/digest')
-rw-r--r-- | library/cpp/digest/md5/md5.cpp | 30 | ||||
-rw-r--r-- | library/cpp/digest/md5/md5.h | 10 | ||||
-rw-r--r-- | library/cpp/digest/md5/md5_ut.cpp | 10 |
3 files changed, 25 insertions, 25 deletions
diff --git a/library/cpp/digest/md5/md5.cpp b/library/cpp/digest/md5/md5.cpp index 24a5b69eef..53f08271d4 100644 --- a/library/cpp/digest/md5/md5.cpp +++ b/library/cpp/digest/md5/md5.cpp @@ -201,17 +201,17 @@ char* MD5::End_b64(char* buf) { return buf; } -ui64 MD5::EndHalfMix() { +ui64 MD5::EndHalfMix() { ui8 digest[16]; - Final(digest); - ui64 res = 0; - for (int i = 3; i >= 0; i--) { - res |= (ui64)(digest[0 + i] ^ digest[8 + i]) << ((3 - i) << 3); - res |= (ui64)(digest[4 + i] ^ digest[12 + i]) << ((7 - i) << 3); - } - return res; -} - + Final(digest); + ui64 res = 0; + for (int i = 3; i >= 0; i--) { + res |= (ui64)(digest[0 + i] ^ digest[8 + i]) << ((3 - i) << 3); + res |= (ui64)(digest[4 + i] ^ digest[12 + i]) << ((7 - i) << 3); + } + return res; +} + TString MD5::Calc(TStringBuf data) { return Calc(MakeUnsignedArrayRef(data)); } @@ -231,14 +231,14 @@ TString MD5::CalcRaw(const TArrayRef<const ui8>& data) { return result; } -ui64 MD5::CalcHalfMix(const char* data, size_t len) { +ui64 MD5::CalcHalfMix(const char* data, size_t len) { return CalcHalfMix(MakeUnsignedArrayRef(data, len)); -} - +} + ui64 MD5::CalcHalfMix(TStringBuf data) { return CalcHalfMix(MakeUnsignedArrayRef(data)); -} - +} + ui64 MD5::CalcHalfMix(const TArrayRef<const ui8>& data) { return MD5().Update(data).EndHalfMix(); } diff --git a/library/cpp/digest/md5/md5.h b/library/cpp/digest/md5/md5.h index 2c17aa0518..74e27cd4ed 100644 --- a/library/cpp/digest/md5/md5.h +++ b/library/cpp/digest/md5/md5.h @@ -35,9 +35,9 @@ public: // buf must be char[25]; char* End_b64(char* buf); - // 8-byte xor-based mix - ui64 EndHalfMix(); - + // 8-byte xor-based mix + ui64 EndHalfMix(); + MD5& Update(IInputStream* in); /* @@ -61,8 +61,8 @@ public: static ui64 CalcHalfMix(TStringBuf data); static ui64 CalcHalfMix(const TArrayRef<const ui8>& data); - static ui64 CalcHalfMix(const char* data, size_t len); - + static ui64 CalcHalfMix(const char* data, size_t len); + static bool IsMD5(TStringBuf data); static bool IsMD5(const TArrayRef<const ui8>& data); diff --git a/library/cpp/digest/md5/md5_ut.cpp b/library/cpp/digest/md5/md5_ut.cpp index 1c3e4ad0a9..1710d07052 100644 --- a/library/cpp/digest/md5/md5_ut.cpp +++ b/library/cpp/digest/md5/md5_ut.cpp @@ -58,9 +58,9 @@ Y_UNIT_TEST_SUITE(TMD5Test) { UNIT_ASSERT_EQUAL(true, MD5::IsMD5(TStringBuf("4136ebb0E4C45D21e2b09294C75CfA08"))); UNIT_ASSERT_EQUAL(true, MD5::IsMD5(TStringBuf("4136ebb0e4c45d21e2b09294c75cfa08"))); } - - Y_UNIT_TEST(TestMd5HalfMix) { - UNIT_ASSERT_EQUAL(MD5::CalcHalfMix(""), 7203772011789518145ul); - UNIT_ASSERT_EQUAL(MD5::CalcHalfMix("qwertyuiopqwertyuiopasdfghjklasdfghjkl"), 11753545595885642730ul); - } + + Y_UNIT_TEST(TestMd5HalfMix) { + UNIT_ASSERT_EQUAL(MD5::CalcHalfMix(""), 7203772011789518145ul); + UNIT_ASSERT_EQUAL(MD5::CalcHalfMix("qwertyuiopqwertyuiopasdfghjklasdfghjkl"), 11753545595885642730ul); + } } |