crc

How could I guess a checksum algorithm?

浪子不回头ぞ 提交于 2019-11-27 20:41:03
Let's assume that I have some packets with a 16-bit checksum at the end. I would like to guess which checksum algorithm is used. For a start, from dump data I can see that one byte change in the packet's payload totally changes the checksum, so I can assume that it isn't some kind of simple XOR or sum. Then I tried several variations of CRC16 , but without much luck. This question might be more biased towards cryptography, but I'm really interested in any easy to understand statistical tools to find out which CRC this might be. I might even turn to drawing different CRC algorithms if

Get CRC checksum of an NSData in Objective-C

时光怂恿深爱的人放手 提交于 2019-11-27 19:50:37
How can I count CRC (32 or 64) of an NSData object in Objective-C? Thanks in advance! Have a look here for a CRC32 for NSData http://classroomm.com/objective-c/index.php?action=printpage;topic=2891.0 Use crc32() function from zlib library: #import <zlib.h> NSData *data; // ... unsigned long result = crc32(0, data.bytes, data.length); NSLog(@"CRC32: %lu", result); Make sure to link libz library with your project: From iOS11 use this: unsigned long result = crc32_z(0, data.bytes, data.length); 来源: https://stackoverflow.com/questions/4115059/get-crc-checksum-of-an-nsdata-in-objective-c

How to configure calculation of CRC table

二次信任 提交于 2019-11-27 18:53:30
问题 There are a lot of CRC calculation examples out there. Simple implementations with bit shifting and more efficient with a pre-calculated table. But there are also a lot of Parameters of a CRC beside the polynomial that affect the calculation. You can evaluate these parameters here: http://zorc.breitbandkatze.de/crc.html These parameters are initial value of CRC reflection of input data reflection of output data final XOR value for CRC For some "standard" CRC algorithm these parameters are

Function to Calculate a CRC16 Checksum

家住魔仙堡 提交于 2019-11-27 17:26:37
I'm working on a library to provide simple reliable communication over an RS232 or RS485 connection. Part of this code involves using a CRC16 checksum on the data to detect corruption from line noise. I've created a function to calculate a CRC16 checksum, but it doesn't seem to be outputting correct values. The relevant code I've written is below (it can also be found here ). #include <stdint.h> #define CRC16 0x8005 uint16_t gen_crc16(const uint8_t *data, uint16_t size) { uint16_t out = 0; int bits_read = 0, bit_flag; /* Sanity check: */ if(data == NULL) return 0; while(size > 0) { bit_flag =

Data Length vs CRC Length

删除回忆录丶 提交于 2019-11-27 14:33:26
问题 I've seen 8-bit, 16-bit, and 32-bit CRCs. At what point do I need to jump to a wider CRC? My gut reaction is that it is based on the data length: 1-100 bytes: 8-bit CRC 101 - 1000 bytes: 16-bit CRC 1001 - ??? bytes: 32-bit CRC EDIT: Looking at the Wikipedia page about CRC and Lott's answer, here' what we have: <64 bytes: 8-bit CRC <16K bytes: 16-bit CRC <512M bytes: 32-bit CRC 回答1: It's not a research topic. It's really well understood: http://en.wikipedia.org/wiki/Cyclic_redundancy_check The

CRC校验学习

随声附和 提交于 2019-11-27 13:06:11
上面文字是来自一个 版本的介绍crc校验方式的介绍, 下面截图是一个视频crc校验原理的讲解。 通过这两部分才彻底弄清楚了crc是怎么计算的。 上部分来自 https://blog.csdn.net/weicao1990/article/details/51669853 视频来自 https://v.qq.com/x/page/l0812ydj8i2.html 1. CRC校验原理 CRC校验原理看起来比较复杂,好难懂,因为大多数书上基本上是以二进制的多项式形式来说明的。其实很简单的问题,其根本思想就是先在要发送的帧后面附加一个数(这个就是用来校验的校验码,但要注意,这里的数也是二进制序列的,下同),生成一个新帧发送给接收端。当然,这个附加的数不是随意的,它要使所生成的新帧能与发送端和接收端共同选定的某个特定数整除(注意,这里不是直接采用二进制除法,而是采用一种称之为“ 模2除法 ”)。到达接收端后,再把接收到的新帧除以(同样采用“ 模2除法 ”)这个选定的除数。因为在发送端发送数据帧之前就已通过附加一个数,做了“去余”处理(也就已经能整除了),所以结果应该是没有余数。如果有余数,则表明该帧在传输过程中出现了差错。 【说明】“模2除法”与“算术除法”类似,但它既不向上位借位,也不比较除数和被除数的相同位数值的大小,只要以相同位数进行相除即可。模2加法运算为:1+1=0,0+1=1

CRC32 Collision

别来无恙 提交于 2019-11-27 12:29:24
I am trying to find a collision between two messages that will lead to the same CRC hash. Considering I am using CRC32, is there any way I can shorten the list of possible messages I have to try when doing a brute force attack? Any links to websites with hints on this will be helpful. I already have a brute force algorithm that will do this but it simply increment integers and sees if it will match other hashes. scruffy_brit It depends entirely on what you mean by "message". If you can append four bytes of gibberish to one of the messages. (I.E. four bytes that have no meaning within the

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

末鹿安然 提交于 2019-11-27 09:15:27
问题 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 回答1: 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. 回答2: Unless you're using a

How to generate a CRC-16 from C#

落花浮王杯 提交于 2019-11-27 08:06:42
I am trying to generate a CRC-16 using C#. The hardware I am using for RS232 requires the input string to be HEX. The screenshot below shows the correct conversion, For a test, I need 8000 to be 0xC061, however the C# method that generates CRC-16 must be able to convert any given HEX string. I have tried using Nito.KitchenSink.CRC I have also tried the below which generates 8009 when 8000 is inputted - public string CalcCRC16(string strInput) { ushort crc = 0x0000; byte[] data = GetBytesFromHexString(strInput); for (int i = 0; i < data.Length; i++) { crc ^= (ushort)(data[i] << 8); for (int j =

crc16 implementation java

时间秒杀一切 提交于 2019-11-27 06:14:30
问题 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,