crc

What is the fastest hash algorithm to check if two files are equal?

馋奶兔 提交于 2019-11-28 15:38:43
What is the fastest way to create a hash function which will be used to check if two files are equal? Security is not very important. Edit: I am sending a file over a network connection, and will be sure that the file on both sides are equal One approach might be to use a simple CRC-32 algorithm, and only if the CRC values compare equal, rerun the hash with a SHA1 or something more robust. A fast CRC-32 will outperform a cryptographically secure hash any day. Unless you're using a really complicated and/or slow hash, loading the data from the disk is going to take much longer than computing

CRC8-Check in PHP

萝らか妹 提交于 2019-11-28 12:59:10
How can I generate a CRC-8 checksum in PHP? function crcnifull ($dato, $byte) { static $PolyFull=0x8c; for ($i=0; $i<8; $i++) { $x=$byte&1; $byte>>=1; if ($dato&1) $byte|=0x80; if ($x) $byte^=$PolyFull; $dato>>=1; } return $byte; } function crc8 (array $ar,$n=false) { if ($n===false) $n=count($ar); $crcbyte=0; for ($i=0; $i<$n; $i++) $crcbyte=crcnifull($ar[$i], $crcbyte); return $crcbyte; } To use this function for a binary string you have to convert the binary string to an array first. That can be achieved like this: function sbin2ar($sbin) { $ar=array(); $ll=strlen($sbin); for ($i=0; $i<$ll;

crc16 implementation java

寵の児 提交于 2019-11-28 11:32:26
I am having problems with calculating CRC-16 implementation of a byte array in java. Basically I am trying to send bytes to a RFID that starts writing to a tag. I can see the checksum value of array by looking tcpdump command on mac. But my goal is to generate it by myself. Here is my byte array which should generate 0xbe,0xd9: byte[] bytes = new byte[]{(byte) 0x55,(byte) 0x08,(byte) 0x68, (byte) 0x14, (byte) 0x93, (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x06, (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x13, (byte) 0x50, (byte) 0x00,

CRC校验码

社会主义新天地 提交于 2019-11-28 11:12:21
例如:g(x)=x^4+x^3+x^2+1,(7,3)码,信息码110产生的CRC码就是1001。 对于g(x)=x^4+x^3+x^2+1的解释:(都是从右往左数)x4就是第五位是1,因为没有x1所以第2位就是0。 11101 | 110,0000(设a=11101 ,b=1100000) 用b除以a做模2运算得到余数:1001 余数是1001,所以CRC码是1001,传输码为:110,1001 来源: https://www.cnblogs.com/achangchang/p/11406183.html

Methods to nail down 16 bit CRC/Checksum algorithm used by Windows CE executable?

泄露秘密 提交于 2019-11-28 10:23:22
I need to reverse engineer CRC/Checksum algorithm implemented by windows CE executable. Being propritory protocol, it does not say anything about CRC/checksum algorithm. However, There is console interface that reports correct/calculated checksum and I can construct my own messages with random bits if message protocol is correct: I have observed that, Changing single bit in message changes checksum bytes completely. Algorithm seems to be position dependent as I fed some single 1 bit messages in various message data positions with rest of the bits zero and all the time console reported

Convert C CRC16 to Java CRC16

…衆ロ難τιáo~ 提交于 2019-11-28 10:11:37
I am currently working on a project, having an embedded system sending data to a PC via radio. The packets get a crc16 checksum at the end and it's calculated based on this algorithm: uint16_t crc16 (const uint8_t * buffer, uint32_t size) { uint16_t crc = 0xFFFF; if (buffer && size) while (size--) { crc = (crc >> 8) | (crc << 8); crc ^= *buffer++; crc ^= ((unsigned char) crc) >> 4; crc ^= crc << 12; crc ^= (crc & 0xFF) << 5; } return crc; } Now I am looking for an equivalent in Java. I already found a good one here: http://introcs.cs.princeton.edu/java/51data/CRC16CCITT.java.html public class

CRC(循环冗余校验)

与世无争的帅哥 提交于 2019-11-28 05:57:32
在线计算: http://www.ip33.com/crc.html 原文链接:https://blog.csdn.net/liyuanbhu/article/details/7882789 写给嵌入式程序员的循环冗余校验(CRC)算法入门引导 前言 CRC校验(循环冗余校验)是数据通讯中最常采用的校验方式。在嵌入式软件开发中,经常要用到CRC 算法对各种数据进行校验。因此,掌握基本的CRC算法应是嵌入式程序员的基本技能。可是,我认识的嵌入式程序员中能真正掌握CRC算法的人却很少,平常在项目中见到的CRC的代码多数都是那种效率非常低下的实现方式。 其实,在网上有一篇介绍CRC 算法的非常好的文章,作者是Ross Williams,题目叫:“A PAINLESS GUIDE TO CRC ERROR DETECTION ALGORITHMS”。我常将这篇文章推荐给向我询问CRC算法的朋友,但不少朋友向我抱怨原文太长了,而且是英文的。希望我能写篇短点的文章,因此就有了本文。不过,我的水平比不了Ross Williams,我的文章肯定也没Ross Williams的写的好。因此,阅读英文没有障碍的朋友还是去读Ross Williams的原文吧。 本文的读者群设定为软件开发人员,尤其是从事嵌入式软件开发的程序员,而不是专业从事数学或通讯领域研究的学者(我也没有这个水平写的这么高深)。因此

CRC-4 implementation in C#

大城市里の小女人 提交于 2019-11-28 05:29:32
问题 I've been searching the net for a C# implementation of the 4-bit cyclic redundancy check (CRC-4-ITU) but so far I've been unsuccessful. Is there anyone who's able to give me a reference implementation of CRC-4-ITU? Preferrably with the standard polynomial if there is a standard polynomial (I've read the spec pointed to by wikipedia as the CRC4 spec without finding a definition of the polynomial). I'd also really appreciate some sort of test suite or test data to verify a CRC4 implementation.

definitive CRC for C

跟風遠走 提交于 2019-11-28 05:28:06
Since CRC is so widely used, I'm surprised by having a hard time finding CRC implementations in C. Is there a "definitive" CRC calculation snippet/algorithm for C, that "everyone" uses? Or: is there a good CRC implementation somebody can vouch for, and point me towards? I'm looking for CRC8 and CRC16 implementations in particular. Come to think of it, my situation may be a little unconventional. I'm writing C code for Linux, and the code should eventually be ported to a microcontroller. It seems some microcontroller APIs do come with CRC implementations; in any case, I'm looking for a generic

CRC Calculation Of A Mostly Static Data Stream

对着背影说爱祢 提交于 2019-11-27 22:22:48
Background: I have a section of memory, 1024 bytes. The last 1020 bytes will always be the same. The first 4 bytes will change (serial number of a product). I need to calculate the CRC-16 CCITT (0xFFFF starting, 0x1021 mask) for the entire section of memory, CRC_WHOLE . Question: Is it possible to calculate the CRC for only the first 4 bytes, CRC_A , then apply a function such as the one below to calculate the full CRC? We can assume that the checksum for the last 1020 bytes, CRC_B , is already known. CRC_WHOLE = XOR(CRC_A, CRC_B) I know that this formula does not work (tried it), but I am