37
crc.c
Normal file
37
crc.c
Normal file
@@ -0,0 +1,37 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include "CRCLib.h"
|
||||
|
||||
int png_signature[8] = { 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a };
|
||||
//int idat_signature[4] = { 0x, 0x, 0x, 0x}
|
||||
|
||||
int CheckPNG(int *addr) {
|
||||
int signature_match = 0;
|
||||
for( int i = 0; i < 8; i++ ) {
|
||||
if (addr[i] != png_signature[i]) {
|
||||
signature_match = 1;
|
||||
}
|
||||
}
|
||||
printf("%d", signature_match);
|
||||
return signature_match;
|
||||
|
||||
}
|
||||
|
||||
void main() {
|
||||
FILE *fp;
|
||||
int c;
|
||||
int myArray[255] = {};
|
||||
int i = 0;
|
||||
fp = fopen("./1.png", "rt");
|
||||
while((c = fgetc(fp)) != EOF) {
|
||||
//printf("Value: %X\n", c);
|
||||
myArray[i] = c;
|
||||
i++;
|
||||
}
|
||||
fclose(fp);
|
||||
CheckPNG(myArray);
|
||||
//printf("%d\n", CheckPNG(myArray));
|
||||
//int crcnum = crc(myArray, 19);
|
||||
//printf("%08X\n", crcnum);
|
||||
}
|
||||
Reference in New Issue
Block a user