MCPcopy Create free account
hub / github.com/F-Stack/f-stack / xorDigest

Function xorDigest

app/redis-6.2.6/src/debug.c:79–90  ·  view source on GitHub ↗

Compute the sha1 of string at 's' with 'len' bytes long. * The SHA1 is then xored against the string pointed by digest. * Since xor is commutative, this operation is used in order to * "add" digests relative to unordered elements. * * So digest(a,b,c,d) will be the same of digest(b,a,c,d) */

Source from the content-addressed store, hash-verified

77 *
78 * So digest(a,b,c,d) will be the same of digest(b,a,c,d) */
79void xorDigest(unsigned char *digest, void *ptr, size_t len) {
80 SHA1_CTX ctx;
81 unsigned char hash[20], *s = ptr;
82 int j;
83
84 SHA1Init(&ctx);
85 SHA1Update(&ctx,s,len);
86 SHA1Final(hash,&ctx);
87
88 for (j = 0; j < 20; j++)
89 digest[j] ^= hash[j];
90}
91
92void xorStringObjectDigest(unsigned char *digest, robj *o) {
93 o = getDecodedObject(o);

Callers 5

xorStringObjectDigestFunction · 0.85
mixDigestFunction · 0.85
xorObjectDigestFunction · 0.85
computeDatasetDigestFunction · 0.85
RM_DigestEndSequenceFunction · 0.85

Calls 3

SHA1InitFunction · 0.70
SHA1UpdateFunction · 0.70
SHA1FinalFunction · 0.70

Tested by

no test coverage detected