mirror of
https://github.com/WerWolv/ImHex-Patterns.git
synced 2026-03-28 07:47:02 -05:00
27 lines
572 B
Plaintext
27 lines
572 B
Plaintext
namespace std::hash {
|
|
|
|
fn crc32(u128 address, u64 size, u32 init, u32 poly) {
|
|
u8 byte;
|
|
u32 crc, mask;
|
|
|
|
crc = init;
|
|
|
|
u64 i;
|
|
while (i < size) {
|
|
byte = std::mem::read_unsigned(address + i, 1);
|
|
crc = crc ^ byte;
|
|
|
|
u8 j;
|
|
while (j < 8) {
|
|
mask = u32(-(crc & 1));
|
|
crc = (crc >> 1) ^ (poly & mask);
|
|
j = j + 1;
|
|
}
|
|
|
|
i = i + 1;
|
|
}
|
|
|
|
return u32(~crc);
|
|
};
|
|
|
|
} |