summaryrefslogtreecommitdiffstatshomepage
path: root/src/tools/split.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/split.cpp')
-rw-r--r--src/tools/split.cpp27
1 files changed, 12 insertions, 15 deletions
diff --git a/src/tools/split.cpp b/src/tools/split.cpp
index ba455c04b51..1748edf7625 100644
--- a/src/tools/split.cpp
+++ b/src/tools/split.cpp
@@ -8,17 +8,19 @@
****************************************************************************/
+#include "corefile.h"
+#include "corestr.h"
+#include "hashing.h"
+
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cassert>
-#include "corefile.h"
-#include "corestr.h"
-#include "sha1.h"
#define DEFAULT_SPLIT_SIZE 100
#define MAX_PARTS 1000
+#define SHA1_DIGEST_SIZE 20
@@ -34,22 +36,17 @@
static void compute_hash_as_string(std::string &buffer, void *data, uint32_t length)
{
- char expanded[SHA1_DIGEST_SIZE * 2];
- uint8_t sha1digest[SHA1_DIGEST_SIZE];
- struct sha1_ctx sha1;
- int ch;
-
// compute the SHA1
- sha1_init(&sha1);
- sha1_update(&sha1, length, (const uint8_t *)data);
- sha1_final(&sha1);
- sha1_digest(&sha1, sizeof(sha1digest), sha1digest);
+ util::sha1_creator sha1;
+ sha1.append(data, length);
+ const util::sha1_t sha1digest = sha1.finish();
// expand the digest to a string
- for (ch = 0; ch < SHA1_DIGEST_SIZE; ch++)
+ char expanded[sizeof(sha1digest.m_raw) * 2];
+ for (int ch = 0; ch < sizeof(sha1digest.m_raw); ch++)
{
- expanded[ch * 2 + 0] = "0123456789ABCDEF"[sha1digest[ch] >> 4];
- expanded[ch * 2 + 1] = "0123456789ABCDEF"[sha1digest[ch] & 15];
+ expanded[ch * 2 + 0] = "0123456789ABCDEF"[sha1digest.m_raw[ch] >> 4];
+ expanded[ch * 2 + 1] = "0123456789ABCDEF"[sha1digest.m_raw[ch] & 15];
}
// copy it to the buffer