diff options
author | dbear496 <70439542+dbear496@users.noreply.github.com> | 2024-09-14 18:21:29 -0400 |
---|---|---|
committer | dbear496 <70439542+dbear496@users.noreply.github.com> | 2024-09-14 18:21:29 -0400 |
commit | 5320c9f719a309ddacdbe77181cabeb351949013 (patch) | |
tree | 80cc98dc8deee853dfb1b76371c745fa286ae9e1 | |
parent | 4f4cc1688a8e8a7c03f18603cc5a4159d9c89ca3 (diff) | |
download | fork-ledger-5320c9f719a309ddacdbe77181cabeb351949013.tar.gz fork-ledger-5320c9f719a309ddacdbe77181cabeb351949013.tar.bz2 fork-ledger-5320c9f719a309ddacdbe77181cabeb351949013.zip |
use sha1sum in anonymize_posts::operator()
-rw-r--r-- | src/filters.cc | 16 | ||||
-rw-r--r-- | src/utils.h | 2 |
2 files changed, 3 insertions, 15 deletions
diff --git a/src/filters.cc b/src/filters.cc index 71d835e6..523fa795 100644 --- a/src/filters.cc +++ b/src/filters.cc @@ -237,8 +237,6 @@ void anonymize_posts::render_commodity(amount_t& amt) void anonymize_posts::operator()(post_t& post) { - boost::uuids::detail::sha1 sha; - boost::uuids::detail::sha1::digest_type message_digest; bool copy_xact_details = false; if (last_xact != post.xact) { @@ -255,12 +253,7 @@ void anonymize_posts::operator()(post_t& post) std::ostringstream buf; buf << reinterpret_cast<boost::uintmax_t>(post.xact->payee.c_str()) << integer_gen() << post.xact->payee.c_str(); - - sha.reset(); - sha.process_bytes(buf.str().c_str(), buf.str().length()); - sha.get_digest(message_digest); - - xact.payee = digest_to_hex(message_digest, 8); + xact.payee = sha1sum(buf.str(), 8); xact.note = none; } else { xact.journal = post.xact->journal; @@ -273,12 +266,7 @@ void anonymize_posts::operator()(post_t& post) acct = acct->parent) { std::ostringstream buf; buf << integer_gen() << acct << acct->fullname(); - - sha.reset(); - sha.process_bytes(buf.str().c_str(), buf.str().length()); - sha.get_digest(message_digest); - - account_names.push_front(digest_to_hex(message_digest, 8)); + account_names.push_front(sha1sum(buf.str(), 8)); } account_t * new_account = diff --git a/src/utils.h b/src/utils.h index e09c603d..13cf26f6 100644 --- a/src/utils.h +++ b/src/utils.h @@ -604,7 +604,7 @@ inline string sha1sum( const string& str, size_t len = sizeof(boost::uuids::detail::sha1::digest_type) * 2 ) { - boost::uuids::detail::sha1 sha; + static boost::uuids::detail::sha1 sha; boost::uuids::detail::sha1::digest_type message_digest; sha.reset(); |