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/sha256.cxx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'libbutl/sha256.cxx') diff --git a/libbutl/sha256.cxx b/libbutl/sha256.cxx index 6dbe2a0..31730a2 100644 --- a/libbutl/sha256.cxx +++ b/libbutl/sha256.cxx @@ -67,7 +67,7 @@ namespace butl { sha256:: sha256 () - : done_ (false) + : done_ (false), empty_ (true) { SHA256_Init (reinterpret_cast (buf_)); } @@ -75,7 +75,13 @@ namespace butl void sha256:: append (const void* b, size_t n) { - SHA256_Update (reinterpret_cast (buf_), b, n); + if (n != 0) + { + SHA256_Update (reinterpret_cast (buf_), b, n); + + if (empty_) + empty_ = false; + } } void sha256:: -- cgit v1.1