MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / xorDigest

Function xorDigest

src/debug.cpp:92–104  ·  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

90 *
91 * So digest(a,b,c,d) will be the same of digest(b,a,c,d) */
92void xorDigest(unsigned char *digest, const void *ptr, size_t len) {
93 SHA1_CTX ctx;
94 unsigned char hash[20];
95 const unsigned char *s = (const unsigned char*)ptr;
96 int j;
97
98 SHA1Init(&ctx);
99 SHA1Update(&ctx,s,len);
100 SHA1Final(hash,&ctx);
101
102 for (j = 0; j < 20; j++)
103 digest[j] ^= hash[j];
104}
105
106void xorStringObjectDigest(unsigned char *digest, robj *o) {
107 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.85
SHA1UpdateFunction · 0.85
SHA1FinalFunction · 0.85

Tested by

no test coverage detected