Skip to content

Commit

Permalink
use sha1sum in anonymize_posts::operator()
Browse files Browse the repository at this point in the history
  • Loading branch information
dbear496 committed Sep 14, 2024
1 parent 4f4cc16 commit 5320c9f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
16 changes: 2 additions & 14 deletions src/filters.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
Expand All @@ -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 =
Expand Down
2 changes: 1 addition & 1 deletion src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 5320c9f

Please sign in to comment.