From 88adf3f7f2e9c6f1ea3c722ead41a5579b3292bf Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 5 Oct 2019 08:30:00 +0200 Subject: Add sha{1,256}::empty() --- libbutl/sha1.cxx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'libbutl/sha1.cxx') 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 (buf_)); } @@ -81,7 +81,13 @@ namespace butl void sha1:: append (const void* b, size_t n) { - SHA1_Update (reinterpret_cast (buf_), b, n); + if (n != 0) + { + SHA1_Update (reinterpret_cast (buf_), b, n); + + if (empty_) + empty_ = false; + } } void sha1:: -- cgit v1.1