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

Function getCheckSum

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

* Create a unique checksum hashing the fingerprint and a few other values. * @param {string} serializedIds * @param {number=} opt_offsetMin * @return {string}

(serializedIds, opt_offsetMin)

Source from the content-addressed store, hash-verified

110 * @return {string}
111 */
112function getCheckSum(serializedIds, opt_offsetMin) {
113 const fingerprint = getFingerprint();
114 const offset = opt_offsetMin || 0;
115 const timestamp = getMinSinceEpoch() - offset;
116 const crc = crc32([fingerprint, timestamp, serializedIds].join(DELIMITER));
117 // Encoded to base36 for less bytes.
118 return crc.toString(36);
119}
120
121/**
122 * Generates a semi-unique value for page visitor.

Callers 2

createLinkerFunction · 0.70
isCheckSumValidFunction · 0.70

Calls 4

crc32Function · 0.90
getFingerprintFunction · 0.70
getMinSinceEpochFunction · 0.70
toStringMethod · 0.45

Tested by

no test coverage detected