Created
September 15, 2011 17:18
-
-
Save mmalex/1219860 to your computer and use it in GitHub Desktop.
untest implementation of @deplinenoise's amiga checksum
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <arpa/inet.h> // for htonl | |
int main(int argc, char **argv){ | |
unsigned int c=0,d,i,block[256]={0}; | |
fread(block,1,1024,fopen(argv[1],"rb")); | |
for (i=0;i<256;++i) | |
if (c > (d=c+htonl(block[i]))) c=d+1; else c=d; | |
block[1]=htonl(c)^0xffffffff; | |
fwrite(block,1,1024,fopen(argv[2],"wb")); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment