diff options
author | thegeorg <thegeorg@yandex-team.ru> | 2022-02-10 16:45:12 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:12 +0300 |
commit | 49116032d905455a7b1c994e4a696afc885c1e71 (patch) | |
tree | be835aa92c6248212e705f25388ebafcf84bc7a1 /library/cpp/digest/md5 | |
parent | 4e839db24a3bbc9f1c610c43d6faaaa99824dcca (diff) | |
download | ydb-49116032d905455a7b1c994e4a696afc885c1e71.tar.gz |
Restoring authorship annotation for <thegeorg@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/digest/md5')
-rw-r--r-- | library/cpp/digest/md5/md5.cpp | 36 | ||||
-rw-r--r-- | library/cpp/digest/md5/md5.h | 16 |
2 files changed, 26 insertions, 26 deletions
diff --git a/library/cpp/digest/md5/md5.cpp b/library/cpp/digest/md5/md5.cpp index 9a28c3d8f3..24a5b69eef 100644 --- a/library/cpp/digest/md5/md5.cpp +++ b/library/cpp/digest/md5/md5.cpp @@ -9,11 +9,11 @@ #include <contrib/libs/nayuki_md5/md5.h> namespace { - + constexpr size_t MD5_BLOCK_LENGTH = 64; constexpr size_t MD5_PADDING_SHIFT = 56; - constexpr size_t MD5_HEX_DIGEST_LENGTH = 32; - + constexpr size_t MD5_HEX_DIGEST_LENGTH = 32; + struct TMd5Stream: public IOutputStream { inline TMd5Stream(MD5* md5) : M_(md5) @@ -48,13 +48,13 @@ char* MD5::File(const char* filename, char* buf) { } TString MD5::File(const TString& filename) { - TString buf; - buf.ReserveAndResize(MD5_HEX_DIGEST_LENGTH); - auto result = MD5::File(filename.data(), buf.begin()); - if (result == nullptr) { - buf.clear(); - } - return buf; + TString buf; + buf.ReserveAndResize(MD5_HEX_DIGEST_LENGTH); + auto result = MD5::File(filename.data(), buf.begin()); + if (result == nullptr) { + buf.clear(); + } + return buf; } char* MD5::Data(const TArrayRef<const ui8>& data, char* buf) { @@ -66,16 +66,16 @@ char* MD5::Data(const void* data, size_t len, char* buf) { } TString MD5::Data(const TArrayRef<const ui8>& data) { - TString buf; - buf.ReserveAndResize(MD5_HEX_DIGEST_LENGTH); + TString buf; + buf.ReserveAndResize(MD5_HEX_DIGEST_LENGTH); Data(data, buf.begin()); - return buf; -} - -TString MD5::Data(TStringBuf data) { + return buf; +} + +TString MD5::Data(TStringBuf data) { return Data(MakeUnsignedArrayRef(data)); -} - +} + char* MD5::Stream(IInputStream* in, char* buf) { return MD5().Update(in).End(buf); } diff --git a/library/cpp/digest/md5/md5.h b/library/cpp/digest/md5/md5.h index 674ab9dac0..2c17aa0518 100644 --- a/library/cpp/digest/md5/md5.h +++ b/library/cpp/digest/md5/md5.h @@ -1,6 +1,6 @@ #pragma once -#include <util/generic/array_ref.h> +#include <util/generic/array_ref.h> #include <util/generic/strbuf.h> class IInputStream; @@ -40,18 +40,18 @@ public: MD5& Update(IInputStream* in); - /* - * Return hex-encoded md5 checksum for given file. - * - * Return nullptr / empty string if the file does not exist. - */ + /* + * Return hex-encoded md5 checksum for given file. + * + * Return nullptr / empty string if the file does not exist. + */ 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); static char* Data(const TArrayRef<const ui8>& data, char* buf); static TString Data(const TArrayRef<const ui8>& data); - static TString Data(TStringBuf data); + static TString Data(TStringBuf data); static char* Stream(IInputStream* in, char* buf); static TString Calc(TStringBuf data); // 32-byte hex-encoded |