Skip to content

Instantly share code, notes, and snippets.

@qxj
Created August 6, 2012 11:48
Show Gist options
  • Save qxj/3273821 to your computer and use it in GitHub Desktop.
Save qxj/3273821 to your computer and use it in GitHub Desktop.
crc32 in zlib
/* @(#)test_crc32.cpp
* Time-stamp: < 2011-12-26 11:30:17>
* Copyright 2011
* Version: $Id: test_crc32.c,v 0.0 2011/12/26 03:25:28 jqian Exp $
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <zlib.h>
void test_crc32(const char* str){
uLong crc = crc32(0L, Z_NULL, 0);
int len = strlen(str);
crc = crc32(crc, (const Bytef*)str, len);
printf("%u\n", crc);
}
int main(int argc, char *argv[]){
const char str[5][10] = {
"123455",
"123456",
"123457",
"123458",
"123459"
};
for (int i = 0; i < 5; ++i) {
test_crc32(str[i]);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment