Skip to content

Instantly share code, notes, and snippets.

@mmalex
Created September 15, 2011 17:18
Show Gist options
  • Select an option

  • Save mmalex/1219860 to your computer and use it in GitHub Desktop.

Select an option

Save mmalex/1219860 to your computer and use it in GitHub Desktop.

Revisions

  1. @invalid-email-address Anonymous created this gist Sep 15, 2011.
    11 changes: 11 additions & 0 deletions gistfile1.c
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    #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;
    }