MCPcopy Create free account
hub / github.com/ampproject/amphtml / isCheckSumValid

Function isCheckSumValid

extensions/amp-analytics/0.1/linker.js:96–104  ·  view source on GitHub ↗

* Check if the checksum is valid with time offset tolerance. * @param {string} serializedIds * @param {string} checksum * @return {boolean}

(serializedIds, checksum)

Source from the content-addressed store, hash-verified

94 * @return {boolean}
95 */
96function isCheckSumValid(serializedIds, checksum) {
97 for (let i = 0; i <= CHECKSUM_OFFSET_MAX_MIN; i++) {
98 const calculateCheckSum = getCheckSum(serializedIds, i);
99 if (calculateCheckSum == checksum) {
100 return true;
101 }
102 }
103 return false;
104}
105
106/**
107 * Create a unique checksum hashing the fingerprint and a few other values.

Callers 1

parseLinkerFunction · 0.70

Calls 1

getCheckSumFunction · 0.70

Tested by

no test coverage detected