MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / crc32

Function crc32

mserver/Client/src/framing.rs:19–32  ·  view source on GitHub ↗

Standard reflected IEEE CRC-32 (poly `0xEDB88320`, init/final `0xFFFFFFFF`) — equals the engine's `crc32(0, buf, len)`.

(data: &[u8])

Source from the content-addressed store, hash-verified

17/// Standard reflected IEEE CRC-32 (poly `0xEDB88320`, init/final `0xFFFFFFFF`) — equals
18/// the engine's `crc32(0, buf, len)`.
19pub fn crc32(data: &[u8]) -> u32 {
20 let mut crc: u32 = 0xFFFF_FFFF;
21 for &byte in data {
22 crc ^= u32::from(byte);
23 for _ in 0..8 {
24 crc = if crc & 1 != 0 {
25 (crc >> 1) ^ 0xEDB8_8320
26 } else {
27 crc >> 1
28 };
29 }
30 }
31 !crc
32}
33
34/// Wrap a magic-packet body in a broadcast `MsgHeader` (flags `MAGIC | TO_BCAST`), filling
35/// the length and CRC. `serial` is echoed back by the server; any value works for a probe.

Callers 3

frame_requestFunction · 0.70
unframe_responseFunction · 0.70
test_crc32.cppFile · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected