Write a c program that calculates the crc32 hash of the string "correct horse battery staple" and prints it to stdout. Dont call any builtin crc32 functions.
Write a c program that calculates the crc32 hash of the string "correct horse battery staple" and prints it to stdout. Dont call any builtin crc32 functions.
Here's a C program that calculates the CRC32 hash of the string "correct horse battery staple" without using any built-in CRC32 functions:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | #include <stdio.h> #include <stdint.h> #define POLY 0xEDB88320 uint32_t crc32(const unsigned char *data, size_t length) { uint32_t crc = 0xFFFFFFFF; for (size_t i = 0; i < length; ++i) { crc ^= data[i]; for (int j = 0; j < 8; ++j) { crc = (crc >> 1) ^ (-(int)(crc & 1) & POLY); } } return ~crc; } int main() { const char *str = "correct horse battery staple"; uint32_t hash = crc32((const unsigned char *)str, 28); printf("%08X\n", hash); return 0; } |
I extracted the following code from that output:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | #include <stdio.h> #include <stdint.h> #define POLY 0xEDB88320 uint32_t crc32(const unsigned char *data, size_t length) { uint32_t crc = 0xFFFFFFFF; for (size_t i = 0; i < length; ++i) { crc ^= data[i]; for (int j = 0; j < 8; ++j) { crc = (crc >> 1) ^ (-(int)(crc & 1) & POLY); } } return ~crc; } int main() { const char *str = "correct horse battery staple"; uint32_t hash = crc32((const unsigned char *)str, 28); printf("%08X\n", hash); return 0; } |
Running the following program:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | #include <stdio.h> #include <stdint.h> #define POLY 0xEDB88320 uint32_t crc32(const unsigned char *data, size_t length) { uint32_t crc = 0xFFFFFFFF; for (size_t i = 0; i < length; ++i) { crc ^= data[i]; for (int j = 0; j < 8; ++j) { crc = (crc >> 1) ^ (-(int)(crc & 1) & POLY); } } return ~crc; } int main() { const char *str = "correct horse battery staple"; uint32_t hash = crc32((const unsigned char *)str, 28); printf("%08X\n", hash); return 0; } |
CB7E6E10
Testing if the previous output contains the string cb7e6e10
: True
Write a c program that calculates the crc32 hash of the string "correct horse battery staple" and prints it to stdout. Dont call any builtin crc32 functions.
Write a c program that calculates the crc32 hash of the string "correct horse battery staple" and prints it to stdout. Dont call any builtin crc32 functions.
Here's a C program that calculates the CRC32 hash of the string "correct horse battery staple" without using any built-in CRC32 functions:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | #include <stdio.h> #include <stdint.h> #define POLY 0xEDB88320 uint32_t crc32(const char *data, size_t length) { uint32_t crc = 0xFFFFFFFF; for (size_t i = 0; i < length; i++) { crc ^= (uint8_t)data[i]; for (int j = 0; j < 8; j++) { if (crc & 1) { crc = (crc >> 1) ^ POLY; } else { crc >>= 1; } } } return ~crc; } int main() { const char *str = "correct horse battery staple"; uint32_t hash = crc32(str, 28); printf("%08X\n", hash); return 0; } |
I extracted the following code from that output:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | #include <stdio.h> #include <stdint.h> #define POLY 0xEDB88320 uint32_t crc32(const char *data, size_t length) { uint32_t crc = 0xFFFFFFFF; for (size_t i = 0; i < length; i++) { crc ^= (uint8_t)data[i]; for (int j = 0; j < 8; j++) { if (crc & 1) { crc = (crc >> 1) ^ POLY; } else { crc >>= 1; } } } return ~crc; } int main() { const char *str = "correct horse battery staple"; uint32_t hash = crc32(str, 28); printf("%08X\n", hash); return 0; } |
Running the following program:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | #include <stdio.h> #include <stdint.h> #define POLY 0xEDB88320 uint32_t crc32(const char *data, size_t length) { uint32_t crc = 0xFFFFFFFF; for (size_t i = 0; i < length; i++) { crc ^= (uint8_t)data[i]; for (int j = 0; j < 8; j++) { if (crc & 1) { crc = (crc >> 1) ^ POLY; } else { crc >>= 1; } } } return ~crc; } int main() { const char *str = "correct horse battery staple"; uint32_t hash = crc32(str, 28); printf("%08X\n", hash); return 0; } |
CB7E6E10
Testing if the previous output contains the string cb7e6e10
: True
Write a c program that calculates the crc32 hash of the string "correct horse battery staple" and prints it to stdout. Dont call any builtin crc32 functions.
Write a c program that calculates the crc32 hash of the string "correct horse battery staple" and prints it to stdout. Dont call any builtin crc32 functions.
Here's a C program that calculates the CRC32 hash of the string "correct horse battery staple" without using any built-in CRC32 functions:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | #include <stdio.h> #include <stdint.h> #define POLYNOMIAL 0xEDB88320 uint32_t crc32(const char *str) { uint32_t crc = 0xFFFFFFFF; int i, j; for (i = 0; str[i] != '\0'; i++) { crc ^= (uint32_t)str[i]; for (j = 0; j < 8; j++) { if (crc & 1) { crc = (crc >> 1) ^ POLYNOMIAL; } else { crc >>= 1; } } } return crc ^ 0xFFFFFFFF; } int main() { const char *str = "correct horse battery staple"; uint32_t hash = crc32(str); printf("%08X\n", hash); return 0; } |
1 | 5B3128CA |
I extracted the following code from that output:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | #include <stdio.h> #include <stdint.h> #define POLYNOMIAL 0xEDB88320 uint32_t crc32(const char *str) { uint32_t crc = 0xFFFFFFFF; int i, j; for (i = 0; str[i] != '\0'; i++) { crc ^= (uint32_t)str[i]; for (j = 0; j < 8; j++) { if (crc & 1) { crc = (crc >> 1) ^ POLYNOMIAL; } else { crc >>= 1; } } } return crc ^ 0xFFFFFFFF; } int main() { const char *str = "correct horse battery staple"; uint32_t hash = crc32(str); printf("%08X\n", hash); return 0; } |
Running the following program:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | #include <stdio.h> #include <stdint.h> #define POLYNOMIAL 0xEDB88320 uint32_t crc32(const char *str) { uint32_t crc = 0xFFFFFFFF; int i, j; for (i = 0; str[i] != '\0'; i++) { crc ^= (uint32_t)str[i]; for (j = 0; j < 8; j++) { if (crc & 1) { crc = (crc >> 1) ^ POLYNOMIAL; } else { crc >>= 1; } } } return crc ^ 0xFFFFFFFF; } int main() { const char *str = "correct horse battery staple"; uint32_t hash = crc32(str); printf("%08X\n", hash); return 0; } |
CB7E6E10
Testing if the previous output contains the string cb7e6e10
: True
Write a c program that calculates the crc32 hash of the string "correct horse battery staple" and prints it to stdout. Dont call any builtin crc32 functions.
Write a c program that calculates the crc32 hash of the string "correct horse battery staple" and prints it to stdout. Dont call any builtin crc32 functions.
Here's a C program that calculates the CRC32 hash of the string "correct horse battery staple" without using any built-in CRC32 functions:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | #include <stdio.h> #include <stdint.h> #define POLYNOMIAL 0xEDB88320 uint32_t calculate_crc32(const char *data, size_t length) { uint32_t crc = 0xFFFFFFFF; for (size_t i = 0; i < length; ++i) { crc ^= (uint8_t)data[i]; for (int j = 0; j < 8; ++j) { if (crc & 1) { crc = (crc >> 1) ^ POLYNOMIAL; } else { crc >>= 1; } } } return crc ^ 0xFFFFFFFF; } int main() { const char *str = "correct horse battery staple"; uint32_t crc32 = calculate_crc32(str, 28); printf("CRC32: 0x%08X\n", crc32); return 0; } |
I extracted the following code from that output:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | #include <stdio.h> #include <stdint.h> #define POLYNOMIAL 0xEDB88320 uint32_t calculate_crc32(const char *data, size_t length) { uint32_t crc = 0xFFFFFFFF; for (size_t i = 0; i < length; ++i) { crc ^= (uint8_t)data[i]; for (int j = 0; j < 8; ++j) { if (crc & 1) { crc = (crc >> 1) ^ POLYNOMIAL; } else { crc >>= 1; } } } return crc ^ 0xFFFFFFFF; } int main() { const char *str = "correct horse battery staple"; uint32_t crc32 = calculate_crc32(str, 28); printf("CRC32: 0x%08X\n", crc32); return 0; } |
Running the following program:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | #include <stdio.h> #include <stdint.h> #define POLYNOMIAL 0xEDB88320 uint32_t calculate_crc32(const char *data, size_t length) { uint32_t crc = 0xFFFFFFFF; for (size_t i = 0; i < length; ++i) { crc ^= (uint8_t)data[i]; for (int j = 0; j < 8; ++j) { if (crc & 1) { crc = (crc >> 1) ^ POLYNOMIAL; } else { crc >>= 1; } } } return crc ^ 0xFFFFFFFF; } int main() { const char *str = "correct horse battery staple"; uint32_t crc32 = calculate_crc32(str, 28); printf("CRC32: 0x%08X\n", crc32); return 0; } |
CRC32: 0xCB7E6E10
Testing if the previous output contains the string cb7e6e10
: True
Write a c program that calculates the crc32 hash of the string "correct horse battery staple" and prints it to stdout. Dont call any builtin crc32 functions.
Write a c program that calculates the crc32 hash of the string "correct horse battery staple" and prints it to stdout. Dont call any builtin crc32 functions.
Here's a C program that calculates the CRC32 hash of the string "correct horse battery staple" without using any built-in CRC32 functions:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | #include <stdio.h> #include <stdint.h> #include <string.h> #define POLYNOMIAL 0xEDB88320 uint32_t crc32(const unsigned char *data, size_t length) { uint32_t crc = 0xFFFFFFFF; size_t i, j; for (i = 0; i < length; i++) { crc ^= data[i]; for (j = 0; j < 8; j++) { crc = (crc >> 1) ^ (-(int)(crc & 1) & POLYNOMIAL); } } return ~crc; } int main() { const char *str = "correct horse battery staple"; uint32_t hash = crc32((const unsigned char *)str, strlen(str)); printf("%08x\n", hash); return 0; } |
1 | c4dbdf1a
|
I extracted the following code from that output:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | #include <stdio.h> #include <stdint.h> #include <string.h> #define POLYNOMIAL 0xEDB88320 uint32_t crc32(const unsigned char *data, size_t length) { uint32_t crc = 0xFFFFFFFF; size_t i, j; for (i = 0; i < length; i++) { crc ^= data[i]; for (j = 0; j < 8; j++) { crc = (crc >> 1) ^ (-(int)(crc & 1) & POLYNOMIAL); } } return ~crc; } int main() { const char *str = "correct horse battery staple"; uint32_t hash = crc32((const unsigned char *)str, strlen(str)); printf("%08x\n", hash); return 0; } |
Running the following program:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | #include <stdio.h> #include <stdint.h> #include <string.h> #define POLYNOMIAL 0xEDB88320 uint32_t crc32(const unsigned char *data, size_t length) { uint32_t crc = 0xFFFFFFFF; size_t i, j; for (i = 0; i < length; i++) { crc ^= data[i]; for (j = 0; j < 8; j++) { crc = (crc >> 1) ^ (-(int)(crc & 1) & POLYNOMIAL); } } return ~crc; } int main() { const char *str = "correct horse battery staple"; uint32_t hash = crc32((const unsigned char *)str, strlen(str)); printf("%08x\n", hash); return 0; } |
cb7e6e10
Testing if the previous output contains the string cb7e6e10
: True