1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
int main (int argc, const char *argv[])
{
unsigned char checksum[128] = {0};
const char *fName = "text.txt";
unsigned int index = 0;
cMedal medal;
int fLength = medal.FileSize(fName);
char *buffer = new char[fLength];
int amountRead = 0;
cout<<"--SIZE OF FILE:: "<<fLength<<"\n";
ifstream file("text.txt", ios::binary);
//Stash the contents of our file into our dynamically allocated buffer
while(file>>buffer[amountRead] && amountRead < fLength)
{
amountRead++;
}
int i;
//Process data while the index counter is less than the length of the file.
while(index <= fLength)
{
for(i=0;i<128;i++)
{
//First round is 0+128, second is 0+256, third is 0+384 and so on.
checksum[i] += medal.AA(buffer[(i+index)], 0xe0, 0xb8, 0x77);
checksum[i] += medal.AA(buffer[(i+index)], 0x2f, 0x1b, 0x1f);
checksum[i] += medal.AA(buffer[(i+index)], 0x88, 0xdd, 0x36);
checksum[i] += medal.AA(buffer[(i+index)], 0x25, 0x90, 0x8f);
};
//Increment the index for the buffer
index+=127;
cout<<"\n"<<(i+index);
};
cout<<"\n\n\n";
//Print the checksum
for(int i=0;i<128;i++)
{
printf("%02X", checksum[i]);
}
return 0;
}
|