-1

First off, I'm not sure if this is even the right place for it but I could really use any help.

So I am given an ASCII file that contains the string abcdefghijklmnopqrstuvwxyz12345-ABCDEFGHIJKLMNOPQRSTUVWXYZ12345aand I am supposed to run a CRC-15 polynomial of (1010000001010011) of which its supposed to give me an answer of 1a6a. I'm just trying to wrap my head around on how he got this. I've been using this site https://www.ghsi.de/CRC/, to check to see if I understand it correctly but I keep getting 346a. My understanding is that each character from the string contains a specific hex value for it, thus on using the calculator I rewrite the message in hex with it looking something like 61 62 63 64 65 66 67 68 69 6a... then run the from there.

Anyone mind helping me with anything here?

Yitzak Hernandez
  • 355
  • 4
  • 23
  • Is this a homework assignment by any chance? Also, what have you tried thus far? – Ken Clement Apr 04 '16 at 02:44
  • @KenClement Yes. This is just the beginning steps of the program I have to make, I'm just trying to figure out how he got the `1a6a`. We've done paper assignments but with values much lower to give us an understanding of CRC. I know we have to take the message and translate it into binary, then do an XOR with the polynomial and the remainder would be our answer. Since the message is a too big for paper I don't really have room to try much. – Yitzak Hernandez Apr 04 '16 at 02:56
  • That www.ghsi.de/CRC/ calculator works for me, see (https://www.ghsi.de/CRC/index.php?Polynom=1010000001010011&Message=61+62+63+64+65+66+67+68+69+6A+6B+6C+6D+6E+6F+70+71+72+73+74+75+76+77+78+79+7A+31+32+33+34+35+41+42+43+44+45+46+47+48+49+4A+4B+4C+4D+4E+4F+50+51+52+53+54+55+56+57+58+59+5A+31+32+33+34+35+61+0A). NB: a character of a string doesn't "contain" a hex value, rather the hex value is a way (ASCII) of encoding a char. – agc Apr 04 '16 at 03:04
  • @agc we have to add the `-` character as well to the message and no need to include the `\n` character. But even so, your answer doesn't match with the answer he gave of `1a6a`. Makes me feel as if his answer is wrong. – Yitzak Hernandez Apr 04 '16 at 03:15
  • @RiGid, sorry, just noticed that but you posted before I could delete my comment. BTW, do we know the hyphen is needed? Seeing it at the end of a continued line, I'd thought it was a word wrap. – agc Apr 04 '16 at 03:21
  • @agc Yeah hyphen is needed, it has to be 64 character. – Yitzak Hernandez Apr 04 '16 at 03:26
  • @RiGid on retesting, I get '346a' also. – agc Apr 04 '16 at 03:29
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/108125/discussion-between-agc-and-rigid). – agc Apr 04 '16 at 03:40
  • The CRC has not been sufficiently defined. A CRC is a bit-oriented calculation. Are the bits of each character fed in most-significant first or least-significant first? Should seven or eight bits be fed in per character? What is the initial value of the CRC register? Should the CRC register be exclusive-ored with a constant at the end? How should the CRC register be read out as an integer value (which end becomes the most significant bit of the integer)? – Mark Adler Apr 04 '16 at 18:11
  • @agc yeah professor had the wrong answer haha – Yitzak Hernandez Apr 04 '16 at 21:01

1 Answers1

1

Since this is a homework assignment, I'll give relevant suggestions but no code - that is the job of the student.

  1. Process the string value a byte at a time and for each byte process the bits one at a time. One can parse the bits from a byte string starting with 0x80 and right shifting up to and including 0x01. This produces a mask that can be bit-wise ANDed with the current byte. (an ?: operation or an if statement can be used to disambiguate the value into a 1 or a 0.

  2. Simulate what a hardware circuit would do with that bit. This can be done with simple bit-wise ANDs, XORs, shifts, etc.

  3. It is quite possible to write a simple function that accepts as input the CRC state including the polynomial.

There are multiple ways to go about the calculation, this being only one of them. I have a function of a few lines that performs this calculation as described but as I stated at the outset, the homework assignment is the job of the student.

Good luck to you.

Ken Clement
  • 748
  • 4
  • 13