crc32

Make CRC on stm32 match with software implementation

限于喜欢 提交于 2021-02-19 04:22:45
问题 Upd. See the end of post for working code I'm already mad with this. How can I make checksum from CRC unit on stm32f103 match with software implementation? Stm has polynom 0x04C11DB7 and reset value 0xFFFFFFFF . So I've tried to calculate it in python. Code for stm: uint32_t crc32_hard_block(uint32_t *buf, uint32_t len) { CRC_ResetDR(); uint32_t crc = CRC_CalcBlockCRC(buf, len); return crc; } uint32_t buf[4] = {50, 10, 243, 147}; uint32_t crc_hard_block = crc32_hard_block(buf, 4); Code for

Most efficent way to calculate CRC64 with reflected input

我的未来我决定 提交于 2021-02-07 14:47:47
问题 I need to calculate a CRC-64 using this setup into this wonderful website: http://www.sunshine2k.de/coding/javascript/crc/crc_js.html As you can see I require "input reflected" and that means that I need to reverse the bit order of any byte (a bit annoying). For the moment, I implemented this with a lookup table (for example 0x55 -> 0xAA), but I was wondering if there is any property of CRC which can be used to be more efficient. This is my code (in C): static const unsigned long long CRC64

Python equivalent of unix cksum function

前提是你 提交于 2021-02-06 15:18:01
问题 I've been looking for the equivalent python method for the unix cksum command: http://pubs.opengroup.org/onlinepubs/7990989775/xcu/cksum.html $ cksum ./temp.bin 1605138151 712368 ./temp.bin So far I have found the zlib.crc32() function >>> import zlib >>> f = open('./temp.bin','rb') >>> data = f.read() >>> zlib.crc32(data) 1128751837 However this code appears to produce different results. As far as I can tell this should be using the same crc polynomial but I imagine there must be some

Yet another Java CRC32 implementation related issue

Deadly 提交于 2021-01-29 08:27:50
问题 My problem is when using this implementation; the Java CRC32 calculation is different from C#'s CRC32 calculation using a look-up table. The following is the CRC32 code I am using: public static int CalculateCRCWithTable(byte[] data){ int crc = 0; for (byte b : data) { crc = CRCTable[(crc & 0xff) ^ (b & 0xff)] ^ (crc >>> 8) ; } //crc = crc ^ 0xffffffff; // flip bit/sign return (crc); } Reading from file: public static byte[] readFromFileToByteArray(String fileName) throws IOException {

Verification of a CRC checksum against zero

和自甴很熟 提交于 2021-01-07 01:30:46
问题 I had some contact with the CRC-16 checksum in the past and was accustomed to verifying it by recalculating the CRC-16 checksum over the file I want to verify, plus the 2 bytes of the CRC-16 itself. If the result was zero, then the file integrity was valid, otherwise not. This can be coded very efficiently like with the following pseudo-C: if (recalculated_crc16_checksum != 0) // Error: file integrity is corrupt else // Success: file integrity is valid I recently wanted to use the CRC-32

CRC-32 implementation in java.util.zip.CRC32

帅比萌擦擦* 提交于 2020-12-05 12:04:58
问题 Which CRC-32 algorithm is used in the Java CRC-32 class ? The java doc does not give any details. What is the polynomail used and the initial value for calculaton ? 回答1: According to the source: Computes CRC32 data checksum of a data stream. The actual CRC32 algorithm is described in RFC 1952 (GZIP file format specification version 4.3). Can be used to get the CRC32 over a stream if used with checked input/output streams. The RFC1952 can be found here, but presents a quite technical read. The

CRC-32 implementation in java.util.zip.CRC32

泪湿孤枕 提交于 2020-12-05 12:04:31
问题 Which CRC-32 algorithm is used in the Java CRC-32 class ? The java doc does not give any details. What is the polynomail used and the initial value for calculaton ? 回答1: According to the source: Computes CRC32 data checksum of a data stream. The actual CRC32 algorithm is described in RFC 1952 (GZIP file format specification version 4.3). Can be used to get the CRC32 over a stream if used with checked input/output streams. The RFC1952 can be found here, but presents a quite technical read. The

Calculate a 32-bit CRC lookup table in C/C++

核能气质少年 提交于 2020-06-09 11:17:07
问题 I want to calculate a 32-bit CRC lookup table. One way I tried is by using the following code from this website: #include <iostream> #include <stdint.h> void make_crc_table() { unsigned long POLYNOMIAL = 0x04c11db7; unsigned long WIDTH = 8 * sizeof(unsigned long); unsigned long TOPBIT = 1 << (WIDTH - 1); unsigned long crcTable[256]; unsigned long remainder; // Compute the remainder of each possible dividend for (int dividend = 0; dividend < 256; ++dividend) { // Start with the dividend