Click here to Skip to main content
Sign Up to vote bad
good
See more: C++
Hi everybody. I have been looking for some c++ source code or example for a CRC 128 bits, I already have de polinomial: x128 + x127 + x65 + x64 + x + 1
I have found many examples for crc until crc-32 but I have no idea about how to transform these examples into a crc-128... Could anybody help me in any way? thanks in advance
Posted 8 Nov '12 - 5:55
dpcfire106

Comments
JackDingler - 9 Nov '12 - 16:07
Are you just having trouble implementing 128 bit integers?

1 solution

Try the following (not really a crc but anyway!): http://www.ythorn.com/y/ae/crc.html[^]
  Permalink  
Comments
dpcfire - 9 Nov '12 - 3:11
Thank you very much for your fast answer, I have already been reading that link, but It is not suitable for my development. I have an unsigned char message[256] (including the crc-128 (16 last bytes of message) and I need to check that this crc is correct. I have to implement the ekms crc-128 but I can't find any information about it. I only have the polinomial but I don't know how to obtain the crc. I have found this example (that appears like a generic crc implementation) but I have many problems with the lenght of data (which C++ type do I have to use for the polinomial, and how can I do the mathematical operations with it?): This example is a CRC-16 (I think) #include #include #include void calcula_crc(unsigned longitud, BYTE *mensaje, BYTE *crc) { /* polinomio generador */ char polinomio[] = {1,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0}; /* variables */ unsigned long resultado = -1; char ctl; int i,j,k; /* bucle principal para el calculo del CRC */ for(i = 0; i < longitud; i++) { for(j = 0; j < 8; j++) { ctl = (resultado & 1) ^ ((mensaje >> j) & 1); resultado = (resultado & ~1) >> 1; for(k = 0; k < sizeof(polinomio); k++) { if(ctl && polinomio[sizeof(polinomio) - 1 - k]) resultado ^= (unsigned long) 1 << k; } } } /* pone a cero los bits del resultado no ocupados por el CRC */ for(i = sizeof(polinomio); i < sizeof(resultado) * 8; i++) resultado |= (unsigned long) 1 << i; /* devuelve el CRC de la secuencia */ resultado = ~resultado; resultado >>= 16; crc[0] = resultado & 0xff; crc[1] = (resultado >> 8) & 0xff; } Thank you in advance everybody, I am a bit desperate...
dpcfire - 12 Nov '12 - 3:14
No ideas?...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 564
1 CPallini 245
2 Mahesh Bailwal 239
3 Maciej Los 235
4 Aarti Meswania 208
0 Sergey Alexandrovich Kryukov 9,162
1 OriginalGriff 7,179
2 CPallini 3,913
3 Rohan Leuva 3,176
4 Maciej Los 2,588


Advertise | Privacy | Mobile
Web01 | 2.6.130516.1 | Last Updated 8 Nov 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid