MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / generateChecksum

Function generateChecksum

src/settings/backupRestore.js:38–45  ·  view source on GitHub ↗

* Generates a CRC32 checksum for data integrity verification * More robust than simple hash for detecting corrupted data * @param {string} data * @returns {string}

(data)

Source from the content-addressed store, hash-verified

36 * @returns {string}
37 */
38function generateChecksum(data) {
39 let crc = 0xffffffff;
40 for (let i = 0; i < data.length; i++) {
41 const byte = data.charCodeAt(i) & 0xff;
42 crc = CRC32_TABLE[(crc ^ byte) & 0xff] ^ (crc >>> 8);
43 }
44 return ((crc ^ 0xffffffff) >>> 0).toString(16).padStart(8, "0");
45}
46
47/**
48 * Validates the structure of a backup object

Callers 2

validateBackupStructureFunction · 0.85
backupFunction · 0.85

Calls 1

toStringMethod · 0.45

Tested by

no test coverage detected