crc32_arr(const data[], bool:packed = true, data_len = sizeof data, bool:reset_crc = true) - Description:
- Generates a CRC32 checksum from an array.
- It supports any kind of array including PAWN strings and packed PAWN strings.
- If "packed" is true, all 4 bytes will be used for the computation, otherwise only the lowest byte each cell.
- If "reset_crc" is true, the last checksum will be reset, otherwise it allows procedural computation of a CRC32 checksum.
- Usage:
- Example:
pawn Код:
printf("checksum: 0x%08x", crc32_arr("Hello World")); // Print the checksum of the "Hello World" string printf("checksum: 0x%08x", crc32_arr(!"Hello World")); // Print the checksum of the "Hello World" string, which is packed if(0xFAA6A7FB == crc32_arr("Hello World")) // Compare the checksum of the "Hello World" string with a pre-computed checksum { // Success } else { // Error }
pawn Код:
crc32_arr({10, 20, 30, 40}); // Generate a checksum of the array "{10, 20, 30, 40}" crc32_arr("Hi", _, _, false); // Generate a checksum of the "Hi" string, without resetting the least result (Procedural) new my_checksum = crc32_arr(!"OK", _, _, false); // Generate a checksum of the "OK" string, which is packed, without resetting the least result (Procedural) printf("my_checksum: 0x%08x", my_checksum); // Print "my_checksum" if(0x2A1D7399 == my_checksum) // Compare "my_checksum" with a pre-computed checksum { // Success } else { // Error }
|