mirror of
https://github.com/ggml-org/llama.cpp.git
synced 2026-08-27 15:41:19 +02:00
ed1c3a20f5
* mtmd: use sha256 for input hashing * void conflict with boringssl
24 lines
581 B
C++
24 lines
581 B
C++
#include "hash.h"
|
|
|
|
extern "C" {
|
|
#include "sha256/sha256.h"
|
|
}
|
|
|
|
static std::string to_hex(const unsigned char * digest, size_t len) {
|
|
static const char hex[] = "0123456789abcdef";
|
|
|
|
std::string out;
|
|
out.reserve(2*len);
|
|
for (size_t i = 0; i < len; ++i) {
|
|
out += hex[digest[i] >> 4];
|
|
out += hex[digest[i] & 0xf];
|
|
}
|
|
return out;
|
|
}
|
|
|
|
std::string hash_sha256_hex(const void * data, size_t len) {
|
|
unsigned char digest[SHA256_DIGEST_SIZE];
|
|
sha256_hash(digest, (const unsigned char *) data, len);
|
|
return to_hex(digest, SHA256_DIGEST_SIZE);
|
|
}
|