/* written by Warren M Myers algorithm described April 2005 reference implementation February 2010 algorithm Copyright (c) 2005 by Warren M Myers implementation Copyright (c) 2010 by Warren M Myers use hereby provided for this implementation for anyone and any purpose no warranty granted, express or implied algorithm available for any use by anyone http://warrenmyers.com/blog/2005/04/wolf1-almost-done-and-wolf2-proposed/ */ using namespace std; #include #include // number of 32 bit chunks needed for 256-bit hash #define CHUNK 8 // number of 8-bit characters to be read from file #define LINE 32 unsigned long C[4][CHUNK] = // initialization constants {{0x5538a3e5, 0xf1ef632f, 0x7df8a258, 0xcef9c7ba, 0x765f5cda, 0x497fecf2, 0xfa989ea3, 0xd594974e}, {0xc1eac8f1, 0xc9858068, 0xc9858d68, 0xf489d67b, 0x16a22887, 0x998aa773, 0x342df4ad, 0x9169f4b5}, {0xc3566e73, 0xb8b539b1, 0xf19dbaa9, 0xb7252916, 0x8b3156be, 0x6b3163b7, 0x59318bb2, 0xa4e99a7a}, {0xc477357d, 0x7a69bc6c, 0x6bca3744, 0xb2a0d222, 0xc9a8a8b3, 0x613b5ad5, 0x68588990, 0xbc486357}}; unsigned long R[CHUNK]; unsigned long B[CHUNK]; // current block char tmp[LINE]; // current 32 characters from file - will move to B unsigned long K[CHUNK]; // resultant unsigned long P[6] = {0xaaaaaaaa,0xaaaaaaaa,0xaaaaaaaa,0xaaaaaaaa,0xaaaaaaaa,0xaaaaaaaa}; unsigned long A; unsigned long S; unsigned long kt; void sum(){ for(kt=0;kt<(CHUNK*LINE);){ A += tmp[kt++]; } } void F1(/*B,K,C0*/){ for(kt=0;kt> alternate)); } // is even, rotate right else{ K[kt] = ((K[kt] >> distance) | (K[kt] << alternate)); } } } int main (int argc, char** argv){ A = 0; S = 0; //F7 also performs initialization on R F7(); bool ok = true; unsigned char last = 0; unsigned char segment = CHUNK; // get file - presume it's on commandline for now ifstream infile(argv[1], ios::in | ios::binary); while(ok){ infile.read(tmp,32); if(!infile){ // error - we've hit the end of the file, or non-extant last = infile.gcount(); infile.clear(); ok = false; break; } else{// read was good - put characters into B for(int t=0;t