|
|
@ -18,13 +18,13 @@ std::string MD5::Digest() const { |
|
|
|
MD5& MD5::Update(const void *data, uint64_t len) { |
|
|
|
if (buffer_size_ != 0) { |
|
|
|
if (buffer_size_ + len < 64) { // buffer not filled
|
|
|
|
std::memcpy(buffer_ + buffer_size_, data, len); |
|
|
|
::std::memcpy(buffer_ + buffer_size_, data, len); |
|
|
|
buffer_size_ += len; |
|
|
|
return *this; // save into buffer and return
|
|
|
|
} |
|
|
|
|
|
|
|
auto size = 64 - buffer_size_; |
|
|
|
std::memcpy(buffer_ + buffer_size_, data, size); |
|
|
|
::std::memcpy(buffer_ + buffer_size_, data, size); |
|
|
|
UpdateImpl(buffer_, 64); // fill and update with buffer
|
|
|
|
data = static_cast<const char*>(data) + size; |
|
|
|
buffer_size_ = 0; |
|
|
@ -34,7 +34,7 @@ MD5& MD5::Update(const void *data, uint64_t len) { |
|
|
|
data = UpdateImpl(data, len); |
|
|
|
len &= 0b111111; // len -> [0, 64)
|
|
|
|
if (len != 0) { |
|
|
|
std::memcpy(buffer_, data, len); // save remain data into buffer
|
|
|
|
::std::memcpy(buffer_, data, len); // save remain data into buffer
|
|
|
|
buffer_size_ = len; |
|
|
|
} |
|
|
|
return *this; |
|
|
|