method
Hash.crc32
Hash.crc32(s) -> int
The CRC-32 checksum of a string's bytes — the standard IEEE 802.3 variant (reflected polynomial 0xEDB88320), the same one used by zip, gzip and PNG. Its well-known check value: Hash.crc32("123456789") is 0xCBF43926. Use it to catch accidental corruption in a save file, downloaded asset, or config blob: store the checksum alongside the data and compare on load. It detects damage, not tampering — an attacker can trivially forge a matching CRC, so it is not a security check (see the section note).
Parameters
sthe string (bytes) to checksumExample
program Checksum {
entry {
let data = "save:level=3;coins=120"
let ck = Hash.crc32(data) # store this next to the save; recompute on load
print(ck)
print(Hash.crc32(data) == ck) # 1 — unchanged data checks out
}
}