MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / td_digest

Function td_digest

src/discover/test_conventions.c:222–238  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

220}
221
222static void td_digest(cbm_test_declarations_t *declarations, const char *bytes, size_t len,
223 bool absent) {
224 cbm_sha256_ctx hash;
225 cbm_sha256_init(&hash);
226 const char *domain = absent ? "cbm-test-config-absent-v1" : "cbm-test-config-bytes-v1";
227 cbm_sha256_update(&hash, domain, strlen(domain) + 1);
228 if (len)
229 cbm_sha256_update(&hash, bytes, len);
230 uint8_t digest[CBM_SHA256_DIGEST_LEN];
231 cbm_sha256_final(&hash, digest);
232 static const char hex[] = "0123456789abcdef";
233 for (int i = 0; i < CBM_SHA256_DIGEST_LEN; i++) {
234 declarations->digest[i * 2] = hex[digest[i] >> 4];
235 declarations->digest[i * 2 + 1] = hex[digest[i] & 15];
236 }
237 declarations->digest[CBM_SHA256_HEX_LEN] = '\0';
238}
239
240cbm_test_declarations_t *cbm_test_declarations_parse(const char *bytes, size_t len, bool absent) {
241 if (len > TD_MAX_BYTES || (absent && len) || (!absent && (!bytes || !len)) ||

Callers 1

Calls 3

cbm_sha256_initFunction · 0.85
cbm_sha256_updateFunction · 0.85
cbm_sha256_finalFunction · 0.85

Tested by

no test coverage detected