Hi,
Isn't this a base64 encoding instead of a CRC computation? I need a standard crc64 code, preferably with a #define for the polynomial so that I can generate a CRC64 to crosscheck with database records.
The database includes a CRC32 field, and my job is to change that to a better CRC. This is why I need this CRC to be standard.
Thanks.
Main Topics
Browse All Topics





by: ronaldaungPosted on 2003-04-19 at 03:16:07ID: 8357997
Maybe you could try this ?
z012345" z012345"; z012345678 9" Z+-";
CRC128 is just a pair of CRC64 .. and same for CRC256.
static char base32[] = "abcdefghijklmnopqrstuvwxy
"abcdefghijklmnopqrstuvwxy
static char base64[] = "abcdefghijklmnopqrstuvwxy
"ABCDEFGHIJKLMNOPQRSTUVWXY
int base_encode(const void *data, int size, char **str, char *base)
{
static char tmpbuf[32];
char *p;
char *s;
int i;
int c;
unsigned char *q;
p = s = tmpbuf;
q = (unsigned char*)data;
i=0;
for(i = 0; i < size;){
c=q[i++];
c*=256;
if(i < size)
c+=q[i];
i++;
c*=256;
if(i < size)
c+=q[i];
i++;
p[0]=base[(c&0x00fc0000) >> 18];
p[1]=base[(c&0x0003f000) >> 12];
p[2]=base[(c&0x00000fc0) >> 6];
p[3]=base[(c&0x0000003f) >> 0];
if(i > size)
p[3]='=';
if(i > size+1)
p[2]='=';
p+=4;
}
*p=0;
while (*--p == '=')
*p = 0;
*str = s;
return strlen(s);
}