summaryrefslogtreecommitdiff
path: root/src/xact.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2023-11-30 12:38:44 -0800
committerJohn Wiegley <johnw@newartisans.com>2024-08-05 08:35:56 -0700
commit75e5eacebaf8b9ad3a18b6f1a91a8cb227fa5c9c (patch)
tree896d7f2d1496bd19b2c5ba7a8b97285908bfde0c /src/xact.cc
parentf230125ecc0761e6bd082ac0d916db4f17f0278d (diff)
downloadfork-ledger-75e5eacebaf8b9ad3a18b6f1a91a8cb227fa5c9c.tar.gz
fork-ledger-75e5eacebaf8b9ad3a18b6f1a91a8cb227fa5c9c.tar.bz2
fork-ledger-75e5eacebaf8b9ad3a18b6f1a91a8cb227fa5c9c.zip
Add support for --hashes=sha512_256 as another algorithm
Diffstat (limited to 'src/xact.cc')
-rw-r--r--src/xact.cc5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/xact.cc b/src/xact.cc
index 5c3c7042..ab53794a 100644
--- a/src/xact.cc
+++ b/src/xact.cc
@@ -594,7 +594,7 @@ namespace {
}
}
-string xact_t::hash(string nonce) const {
+string xact_t::hash(string nonce, hash_type_t hash_type) const {
std::ostringstream repr;
repr << nonce;
repr << date();
@@ -621,7 +621,8 @@ string xact_t::hash(string nonce) const {
unsigned char data[128];
string repr_str(repr.str());
SHA512((void *)repr_str.c_str(), repr_str.length(), data);
- return bufferToHex(data, 64 /*SHA512_DIGEST_LENGTH*/);
+ return bufferToHex(
+ data, hash_type == HASH_SHA512 ? 64 : 32 /*SHA512_DIGEST_LENGTH*/);
}
namespace {