diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2019-10-05 08:30:00 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2019-10-05 08:30:00 +0200 |
commit | 88adf3f7f2e9c6f1ea3c722ead41a5579b3292bf (patch) | |
tree | 8329c7f984ea18c6cb35cc1b5ec77f1b39d8656f /libbutl/sha1.cxx | |
parent | f6675a4626267c08e53bbc20bd3dd41ac8744605 (diff) |
Add sha{1,256}::empty()
Diffstat (limited to 'libbutl/sha1.cxx')
-rw-r--r-- | libbutl/sha1.cxx | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/libbutl/sha1.cxx b/libbutl/sha1.cxx index 1ca8a2a..3c1cbdc 100644 --- a/libbutl/sha1.cxx +++ b/libbutl/sha1.cxx @@ -73,7 +73,7 @@ namespace butl { sha1:: sha1 () - : done_ (false) + : done_ (false), empty_ (true) { SHA1_Init (reinterpret_cast<SHA1_CTX*> (buf_)); } @@ -81,7 +81,13 @@ namespace butl void sha1:: append (const void* b, size_t n) { - SHA1_Update (reinterpret_cast<SHA1_CTX*> (buf_), b, n); + if (n != 0) + { + SHA1_Update (reinterpret_cast<SHA1_CTX*> (buf_), b, n); + + if (empty_) + empty_ = false; + } } void sha1:: |