Sunday, July 17, 2011

Catching up



















This blog copyrighted (c) 2008 - 2016 timetravelinstitute.biz





I have been locked out of this blog and I dont know how that happen. I have so very much catching up to do. For starters the conspiracy against time travel and myself that includes Darby of Darbyshire and Ray AKA Rainman using different user names to try to discredit me at different forums. My latest forum was conspiracycafe.net. The owner of that site trashed my account but did not bann me. Long story short my account was too messed up to post anymore. A form of being banned.


I have a video now out on youtube. It will be under reactor1967. Well summer is comming to a end. I am about to get back to some programming. On my code this summer I worked with running a counter where it ran not only in the weak check sum collisions (collisions mean running and staying the same check sum but different files.) But also running and giving weighted check sum collisions. So my counters I did this summer ran at both the same weak check sum and the same weighted check sum which greatly reduced the amount of time to find a result. I found that if you use more than one kind of check sum for the same file and the counter can run giving nothing but the collisions for those check-sums it greatly reduces the amount of time needed to recreate that file with those check sums.

I now call my hobby temporal hacking. Temporal hacking needs both expertise in check-sum hacking and expertise in data mining to find files of the future or the past.

I worked on short-cuts this summer to making my counters run faster. I plan to keep those programs to myself but I will tell you about them.  I developed programs to run a single check-sum counter with different methods for computing check-sums for the same file. A weak check-sum and a weighted check-sum. Let me tell you developing algorithms for running a single check-sum counter giving off collisions for two our more check-sums representing the same file was pure hell to put it nicely. I really had to rack my brain. What I found was that if you take a file and change it so that it still represents more than one check-sum then as you change the file patterns will develop that can be saved and used later to run the counter.

So what I basicly did was run a counter using only one or the other check sum then when the counter equaled both check sums I saved the counter out to a file. Later I went back and looked at these files and found ways I could run a check-sum counter giving off collisions for two different check-sums. Now this method was used for the weak and weighted check sum. I did not use any strong check-sums but if I could have done it I would of made the process of reconstructing a check sum to a file even faster.

Anyway using a rolling check-sum counter giving off collisions for more than one check-sum is a faster way to recreate files knowing only their check-sum or various check-sums using different hash functions. Like I said it did speed the process of recreating files from only their check-sums greatly. But this was all experimental and very time consuming but something that needs to be improved upon later.

So my future work now is to write three programs. One counter program, one data mining robot, and one random number program to create files filled with random numbers. The counter program will randomly fill a file with random bytes and compute the check-sum of the file at the same time.

Then it will randomly add or subtract from the rest of the bytes in the file to bring the file to a specific pre-determined check sum. Then it will then leave this file and go on to create another one. These counter files will be data mined because they are the check-sum collisions off the rolling check-sum counter.

I like to use a random method now because it is a faster optimized way of getting results but the random numbers have to be cryptology grade numbers for this to work. I tested this by using small files first and seeing how long it takes to get all the possible results. This moved to larger and larger files. The larger the files the more this method works. Because the amount of time to find results using a brute force attack is way longer than taking the truly random approach. Some people like Ray aka Rainmain and his cowhand Mr. Darby who have been  two of the disinformation agents trailing me across the internet may disagree with me but that is neither here nor there. Everyone is entitled to their opinions.

Now for this to truly work the random number program has to write files that hold truly random numbers for if they are not random then the counter program will put itself into a loop and we dont want that. So, my random program is ran to create files at specific lengths filled with random numbers then take that file to a randomly selected check-sum by randomly adding or subtracting from the bytes within that file. Then the bytes in the file will be switched around with other bytes. It is the same people I spoke of at space.com and the forum where Tiggs is. This will be are random number file use to run the counter program.

My data mining program will look at the saved counter files to see if they are good. If not they will be deleted. The data-mining is the most complicated part of the process.

So my counter runs and writes files like 1.bin 2.bin 3.bin 4.bin and so forth using random number files devran1 devran2 devran3 devran4 and so forth. It will delete the devran files as it uses them.

There will be some tool programs that can be used with these programs but I have to decide what I want to put with the tool programs. The tools will be programs to help determine what check-sum ranges specific information is in. They will also create and save file formats for the data-mining bots to use. Programs for writting messages, and giving them digital signatures and mac codes and so forth.

I plan to get all three of these programs working for both temporal hacking and check-sum hacking here shortly and I am considering making them available over the internet maybe in a year or two.

So any way I am going to making my programs smaller, faster, and simple as possible. My counter programs will fill up a hard drive with potential files from the future or the past my data-mining bots will search thru those files.

Now I posted a video at youtube In which I said I write messages and give them digital signatures, mac codes (message authorization codes), and what is called a quantum code (one or more events in the time line before the subject of the messages to prove the message is real). These methods go on to shore up my A B algorithm. That if A in the past and B in the future know the weak check-sum range of their messages to each other then both A and B can data mine that check-sum range for their messages to each other thru space-time. Putting in better methods of doing that and tweaking the software around is what I have been doing.


(Update- my youtube video disappeared so I uploaded to blogger.)


And last a side note tonight on how to get truly crypto grade random numbers. A stream of video or video and audio from the environment is a good way. TV recordings or recording the tv left on a noisy channel. The video from such a recording can be broken down into small files or used as a whole file. Part of the recording is used for the counter file. Then Part of the file is used by taken a specific number of bits at a time to create a number from 0 to the length of the counter file to tells us what bytes to modify to bring the counter file to a specific check-sum. In this way using an external source from the environment can cryptology grade numbers be obtained. If a video is used instead of a external noise source then I suggest randomly moving the bytes around in the file with a software random number generator before using the file itself. Anyway we are using part of the external source as a counter file and part of it as a random number generator to bring the counter file to a specific check sum. This way we can avoid the mistakes of a software random number generator taken the counter file into a loop and limiting us as to what results we can find. And one more thing. Since we will be using this method to explore different check-sums for time travel media we can also HEY FATSO DARBY IM USING CAPS AGAIN. REUSE THE RANDOM NUMBER FILES. I like to play around with my disinformation agents from time to time. On the forums they go after me for using caps. Well anyway here are some of my secrets in this blog. Ok im done with this post for tonight.

Oh I could not leave without giving out some computer code. This is the code for the program I was talking about. I have been making improvements to it. This is just one program in a very long line of programs I use for time travel hacking. It is new off the compiler so it might need a few things tweeked here and there. More proof of my claims.

#include


#include


#include


#include


#include


#include


#include


#include <\time codes2\mersennetwister.h="" hacking\fire=""></\time>



// declare user space

using namespace std;



// =======================================================================================



long long weakchecksum(string file1)

{

fstream myfile1;

int x;

long long checksum = 0;

long long begin1;

long long count1;

long long count2;

unsigned char buffer;

long long size1;

long long size2;

long long filesize;



myfile1.open(file1.c_str(), ios:: in
ios:: binary);

if (!myfile1)

{

cout << "122608-12:02 am Unable to open for pic file.\n";

system("pause");

exit(1); // terminate with error

}



myfile1.seekg(0, ios::beg);

size1 = myfile1.tellg();

myfile1.seekg(0, ios::end);

size2 = myfile1.tellg();

filesize = size2 - size1;



count1 = -1;

do

{

count1++;



begin1 = myfile1.tellg();

myfile1.seekg(count1);

if (!myfile1)

{

myfile1.close();

cout << "error in line 51.\n";

system("PAUSE");

exit(1);

}

myfile1.read( reinterpret_cast
( &buffer ),1);

x = (int)buffer;



checksum = checksum + x;



} while (count1 != filesize);

return(checksum);

}



// =======================================================================================

int aicheck(double wcksum) // This AI uses the nearest neighbor method with weighted checksums. It is trained on both negative and postive results.

{

double wchecksum;

int result;

int result2;

double small1 = 99999999;

double small2 = 0;

string file1 = "ai.txt";

fstream myfile1;

myfile1.open(file1.c_str());

if (!myfile1)

{

cout << "ERROR LINE 23\n";

system("pause");

exit(1); // terminate with error

}

do

{

myfile1 >> wchecksum >> result;

small2 = abs(wchecksum - wcksum);

if (small2 < small1)

{

small1 = small2;

result2 = result;

}



}while (!myfile1.eof());

return(result2);

}

// =======================================================================================



double weightedchecksum(string file1)

{





// cout << "Getting weighted check sum\n";

double checksum = 0;

int byte1 = 0;

long long count = -1;

long long filesize1 = 0;

long long begin1 = 0;

long long end1 = 0;

unsigned char buffer;

double x1 = .0000001;

double x2 = .0000001;



// open file1

fstream myfile1(file1.c_str(), ios::in
ios::binary);

if (!myfile1)

{

myfile1.close();

cout << "Failed to read file one.\n";

exit(1);

}





// get filesize1

begin1 = myfile1.tellg();

if (!myfile1)

{

myfile1.close();

cout << "Failed to read file one.\n";

exit(1);

}

myfile1.seekg (0, ios::end);

end1 = myfile1.tellg();

filesize1 = (end1-begin1);



count = -1;

do

{

count++;

byte1 = 0;

// read file1

myfile1.seekg(count);

myfile1.read( reinterpret_cast
( &buffer ),1);

begin1 = myfile1.tellg();

byte1 = (int)buffer;



checksum = checksum + (byte1 * x1);

x1 = x1 + x2;



} while (count < filesize1 - 1);



myfile1.close();

return checksum;



}



// =======================================================================================



string getstrongchecksum()

{

cout << "Get strong checksum.\n";

fstream myfile1;

string file1 = "delme.txt";

system("md5sum counter.bin > delme.txt");

string schecksum = "";



myfile1.open(file1.c_str(), ios:: in);

if (!myfile1)

{

cout << "122608-12:02 am Unable to open\n";

system("pause");

exit(1); // terminate with error

}



myfile1 >> schecksum;

myfile1.close();

system("rm delme.txt");

return(schecksum);



}



// =======================================================================================



int createcounterfile(string file1)

{





// open file1

fstream myfile1(file1.c_str(), ios::out
ios::binary);

if (!myfile1)

{

myfile1.close();

cout << "Failed to read file one.\n";

exit(1);

}





myfile1.close();

}



// =======================================================================================



int createchecksum(string file1, long long cksum, long long filesize1, int minbyte, int maxbyte)

{

// RANDOMONLY WRITE BYTES USING TIME CLOCK. AND GET CHECKSUM THEN TAKE FILE UP OR DOWN.



cout << "Creating check sum file. This could take a while.\n";

long long count = -1;

int byte = 0;

int byte1 = 255;

long long checksum = 0;

unsigned char buffer;

long long begin1;

MTRand mtrand1;



// open file1

fstream myfile1(file1.c_str(), ios::out
ios::in
ios::binary);

if (!myfile1)

{

myfile1.close();

cout << "Failed to read file one.\n";

exit(1);

}



// loop1 create file with filesize all bytes are 255.

count = -1;

checksum = 0;

do

{

cout << "Building checksum file.\n";

count++;

do

{

byte1 = mtrand1.randInt(maxbyte);

} while(byte1 < 48);

// cout << byte1 << "\n";

checksum = checksum + byte1;



// write file1

buffer = (unsigned char)byte1;

myfile1.seekp(count);

myfile1.write( reinterpret_cast
( &buffer ),1);

begin1 = myfile1.tellp();



} while (count < filesize1 - 1);





if (checksum > cksum)

{

do

{



count = mtrand1.randInt( filesize1 - 1 );

// // read file1

myfile1.seekg(count);

myfile1.read( reinterpret_cast
( &buffer ),1);

begin1 = myfile1.tellg();

byte1 = (int)buffer;

cout << "Bring checksum file DOWN." << " " << checksum << " " << cksum << " " << count << " " << byte1 << "\n";

if (byte1 > 0)

{

checksum = checksum - byte1;

byte1 = byte1 - 1;

checksum = checksum + byte1;

}



// WRITE FILE

buffer = (unsigned char)byte1;

myfile1.seekp(count);

myfile1.write( reinterpret_cast
( &buffer ),1);

begin1 = myfile1.tellp();



} while(checksum != cksum);

cout << "Done building checksum file.\n";

myfile1.close();

return(0);





}



if (checksum < cksum)

{

do

{



count = mtrand1.randInt( filesize1 - 1 );

// // read file1

myfile1.seekg(count);

myfile1.read( reinterpret_cast
( &buffer ),1);

begin1 = myfile1.tellg();

byte1 = (int)buffer;

cout << "Bring checksum file UP." << " " << checksum << " " << cksum << " " << count << " " << byte1 << "\n";



if (byte1 < 255)

{

checksum = checksum - byte1;

byte1 = byte1 + 1;

checksum = checksum + byte1;

}



// WRITE FILE

buffer = (unsigned char)byte1;

myfile1.seekp(count);

myfile1.write( reinterpret_cast
( &buffer ),1);

begin1 = myfile1.tellp();



} while(checksum != cksum);

}



cout << "Done building checksum file.\n";

myfile1.close();

return(0);

}



// ==============================================================================





long long filesize(string file1)

{

// cout << "Get file size.\n";

long long begin1;

long long end1;

long long filesize1;



// open file1

fstream myfile1(file1.c_str(), ios::in
ios::binary);

if (!myfile1)

{

myfile1.close();

cout << "Failed to read file one.\n";

system("pause");

exit(1);

}



// get filesize1

begin1 = myfile1.tellg();

if (!myfile1)

{

myfile1.close();

cout << "Failed to read file one.\n";

system("pause");

exit(1);

}

myfile1.seekg (0, ios::end);

end1 = myfile1.tellg();

filesize1 = (end1-begin1);

myfile1.close();

// cout.precision(37);

// cout << filesize1 << "\n";

return(filesize1);

}



// ==============================================================================



// write function to compare weighted sums

int compareweightedsums(double wchecksum, double wcksum)

{



cout << "Comparing weighted sums.\n";

long long filesize1;

long long filesize2;

long long count1;

long long begin1;

long long begin2;

long long end1;

long long end2;

int byte1;

int byte2;

unsigned char(buffer);

ofstream c1myfile;

ofstream c2myfile;



c1myfile.open("compare1.txt");

c2myfile.open("compare2.txt");



c1myfile.precision(37);

c1myfile << wchecksum << "\n";

c2myfile.precision(37);

c2myfile << wcksum << "\n";

c1myfile.close();

c2myfile.close();

fstream myfile1("compare1.txt", ios::in
ios::binary);

fstream myfile2("compare2.txt", ios::in
ios::binary);



// get filesize1

begin1 = myfile1.tellg();

if (!myfile1)

{

myfile1.close();

cout << "Failed to read file one.\n";

exit(1);

}

myfile1.seekg (0, ios::end);

end1 = myfile1.tellg();

filesize1 = (end1-begin1);



// get filesize2

begin2 = myfile2.tellg();

if (!myfile2)

{

myfile2.close();

cout << "Failed to read file two.\n";

exit(1);

}

myfile2.seekg (0, ios::end);

end2 = myfile2.tellg();

filesize2 = (end2-begin2);



count1 = -1;

do

{

count1++;

// read file1

myfile1.seekg(count1);

myfile1.read( reinterpret_cast
( &buffer ),1);

begin1 = myfile1.tellg();

byte1 = (int)buffer;

// read file2

myfile2.seekg(count1);

myfile2.read( reinterpret_cast
( &buffer ),1);

begin2 = myfile2.tellg();

byte2 = (int)buffer;

if (byte1 != byte2)

{

myfile1.close();

myfile2.close();

system("rm compare1.txt");

system("rm compare2.txt");

return(1);

}



} while(count1 < filesize1 - 1 && count1 < filesize2 - 1);

myfile1.close();

myfile2.close();

system("rm compare1.txt");

system("rm compare2.txt");

return(0);

}



// ==============================================================================



// write functin to compare strong checksum

int comparestrongsums(string schecksum, string scksum)

{



cout << "Comparing strong checksums.\n";

long long filesize1;

long long filesize2;

long long count1;

long long begin1;

long long begin2;

long long end1;

long long end2;

int byte1;

int byte2;

unsigned char(buffer);

ofstream c1myfile;

ofstream c2myfile;

ifstream c3myfile;



system("md5sum counter.bin >> out.txt");

c1myfile.open("compare1.txt");

c2myfile.open("compare2.txt");

c3myfile.open("out.txt");





c3myfile >> schecksum;

c3myfile.close();

system("rm out.txt");



c1myfile << schecksum << "\n";

c2myfile << scksum << "\n";

c1myfile.close();

c2myfile.close();



fstream myfile1("compare1.txt", ios::in
ios::binary);

fstream myfile2("compare2.txt", ios::in
ios::binary);



// get filesize1

begin1 = myfile1.tellg();

if (!myfile1)

{

myfile1.close();

cout << "Failed to read file one.\n";

exit(1);

}

myfile1.seekg (0, ios::end);

end1 = myfile1.tellg();

filesize1 = (end1-begin1);



// get filesize2

begin2 = myfile2.tellg();

if (!myfile2)

{

myfile2.close();

cout << "Failed to read file two.\n";

exit(1);

}

myfile2.seekg (0, ios::end);

end2 = myfile2.tellg();

filesize2 = (end2-begin2);



count1 = -1;

do

{

count1++;

// read file1

myfile1.seekg(count1);

myfile1.read( reinterpret_cast
( &buffer ),1);

begin1 = myfile1.tellg();

byte1 = (int)buffer;

// read file2

myfile2.seekg(count1);

myfile2.read( reinterpret_cast
( &buffer ),1);

begin2 = myfile2.tellg();

byte2 = (int)buffer;

if (byte1 != byte2)

{

myfile1.close();

myfile2.close();

system("rm compare1.txt");

system("rm compare2.txt");

return(1);

}



} while(count1 < filesize1 - 1 && count1 < filesize2 - 1);

myfile1.close();

myfile2.close();

system("rm compare1.txt");

system("rm compare2.txt");

return(0);

}



// ==============================================================================



// write function to compare weak checksums

int compareweaksums(long long checksum, long long cksum)

{



cout << "Comparing weak checksums.\n";

long long filesize1;

long long filesize2;

long long count1;

long long begin1;

long long begin2;

long long end1;

long long end2;

int byte1;

int byte2;

unsigned char(buffer);

ofstream c1myfile;

ofstream c2myfile;



c1myfile.open("compare1.txt");

c2myfile.open("compare2.txt");



c1myfile.precision(37);

c1myfile << checksum << "\n";

c2myfile.precision(37);

c2myfile << cksum << "\n";

c1myfile.close();

c2myfile.close();

fstream myfile1("compare1.txt", ios::in
ios::binary);

fstream myfile2("compare2.txt", ios::in
ios::binary);



// get filesize1

begin1 = myfile1.tellg();

if (!myfile1)

{

myfile1.close();

cout << "Failed to read file one.\n";

exit(1);

}

myfile1.seekg (0, ios::end);

end1 = myfile1.tellg();

filesize1 = (end1-begin1);



// get filesize2

begin2 = myfile2.tellg();

if (!myfile2)

{

myfile2.close();

cout << "Failed to read file two.\n";

exit(1);

}

myfile2.seekg (0, ios::end);

end2 = myfile2.tellg();

filesize2 = (end2-begin2);



count1 = -1;

do

{

count1++;

// read file1

myfile1.seekg(count1);

myfile1.read( reinterpret_cast
( &buffer ),1);

begin1 = myfile1.tellg();

byte1 = (int)buffer;

// read file2

myfile2.seekg(count1);

myfile2.read( reinterpret_cast
( &buffer ),1);

begin2 = myfile2.tellg();

byte2 = (int)buffer;

if (byte1 != byte2)

{

myfile1.close();

myfile2.close();

system("rm compare1.txt");

system("rm compare2.txt");

return(1);

}



} while(count1 < filesize1 - 1 && count1 < filesize2 - 1);

myfile1.close();

myfile2.close();

system("rm compare1.txt");

system("rm compare2.txt");

return(0);

}



// ==============================================================================









int main (int argc, char *argv[])



{



// declare variables

int runmeforever = 0;

string file1 = "counter.bin";

string file2 = "";

string file3 = ""; // Will hold file name of counters to be written out.

string file4 = ""; // Will be used for lock files.

string filextension = ""; // This will be the file extension of the counter when written out.

long long cksum = 1578; // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< PROGRAM THIS BEFORE HAND!!!!!!!!!!!!!!!!!!!! example setting

long long checksum = 0;

long long filesize1 = 19; // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< PROGRAM THIS BEFORE HAND!!!!!!!!!!!!!!!!!!!! example setting

long long myresults;

double wcksum = 0.001583699999999999734681677132641652861; // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< PROGRAM THIS BEFORE HAND!!!!!!!!!!!!!!!!!!!! example setting

double wchecksum = 0;

string scksum = "fbd1e673de908d272ebdd0c37a0a286e"; // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< PROGRAM THIS BEFORE HAND!!!!!!!!!!!!!!!!!!!! example setting

string schecksum = "";

int runme = 0;

long long countrandom = -1;

long long randomnumber = 0;

long long mychecksum = 0;

long long filesize2 = 0;

long long howmanypositions = 0;

long long startposition = 0;

long long variablename = 0; // this is the name of the written out counter files without the extension.

int test1;

int test2;

int result;

int minbyte = 0;

int maxbyte = 255;

int byte1 = 0;

int byte2 = 0;

int bitnum = 0;

int randefault = 1;

long long maxchecksum = 0;

long long minchecksum = 0;

long long p1;

long long p2;

MTRand mtrand1;

long long passes;

long long count1;

long long count2;

long long begin1;

long long begin2;

long long begin3;

unsigned char buffer;

int bitpos = 0;

int bitposition;



cout << "FIRE CODES" << "\n";



cout << "\n";



cout << "Select your choice." << "\n";



cout << "\n";



cout << "1. Scramble file" << "\n";



cout << "\n";



cout << "2. Train AI" << "\n";



cout << "\n";



cout << "3. Run check-sum counter with AI data mining." << "\n";



cout << "\n";



cout << "4. Run Fire Codes to reconstruct file." << "\n";



cout << "\n";



cout << "5. Create file with specific weak check-sum and byte size." << "\n";



cout << "\n";



cout << "Any other - Exit." << "\n";



cout << "\n";



// get the response



char choice;



cin >> choice;





// process the response



// do something for each valid option



if (choice=='1') {



// ask how many passes

cout << "How many passes?\n";

cin >> passes;



cout << "What is the name of the file you want to scramble?\n";

cin >> file1;



// get size of file

filesize1 = filesize(file1);

// set counts

count1 = -1; // File pointer

count2 = 0; // This counts the passes



// open file

fstream myfile1(file1.c_str(), ios::out
ios::in
ios::binary);

if (!myfile1)

{

myfile1.close();

cout << "Failed to read file one.\n";

system("pause");

exit(1);

}



// start pass loop

cout << "Working ....\n";

do

{

count2++;

count1 = -1;

//start main loop

do

{





count1++;

//get random byte

long long p2 = mtrand1.randInt(filesize1-1);

// swap current byte with random byte

// byte1 = readfile(file1, count1);

myfile1.seekg(count1);

myfile1.read( reinterpret_cast
( &buffer ),1);

begin1 = myfile1.tellg();

byte1 = (int)buffer;



// byte2 = readfile(file1, p2);

myfile1.seekg(p2);

myfile1.read( reinterpret_cast
( &buffer ),1);

begin1 = myfile1.tellg();

byte2 = (int)buffer;



// runme = writefile(file1, count1, byte2);

buffer = (unsigned char)byte2;

myfile1.seekp(count1);

myfile1.write( reinterpret_cast
( &buffer ),1);

begin1 = myfile1.tellp();



// runme = writefile(file1, p2, byte1);

buffer = (unsigned char)byte1;

myfile1.seekp(p2);

myfile1.write( reinterpret_cast
( &buffer ),1);

begin1 = myfile1.tellp();



// cout << "pass " << count2 << " of " << passes << " " << count1 << " of " << filesize1 - 1 << " " << "swapping position " << count1 << " with position " << p2 << "\n";



// repeat main loop

}while(count1 < filesize1 - 1);

// repeat pass loop

} while(count2 < passes);

myfile1.close();

cout << "Done scrambling file.\n";

system("pause");

exit(0);



} else if (choice=='2') { //



// ask user if these files are for postive or negative result.

cout << "Is this run for a positive or negative result.?\n";

cin >> result;

// ask user name of ai file and tell user this blank file must be created before hand because only appending.

cout << "What is the name of your ai file?\n";

cin >> file3;

// create file list from dir command <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< PUT THIS BACK IN IF RUNNING FOR FIRST TIME OR DO IT MANUALLY. << DEBUG THIS.

// system("dir > filelist.txt");

// cout << "\n";

// cout << "Edit filelist.txt and take out the trash lines if it has any.\n";

// cout << "When done hit enter to continue.\n";

// system("pause");

file1 = "filelist.txt";

fstream myfile1; // filelist

fstream myfile2; // AI file.



myfile1.open(file1.c_str(), ios:: in);

if (!myfile1)

{

cout << "ERROR LINE 447\n";

system("pause");

exit(1); // terminate with error

}



myfile2.open(file3.c_str(), ios:: out); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ERROR THIS ERASES THE PREVIOUS FILE SET THIS UP FOR APPEND NOT CREATE.

if (!myfile2)

{

cout << "ERROR IN LINE 455\n";

system("pause");

exit(1); // terminate with error

}

// start mail loop

do

{

myfile1 >> file2;

wchecksum = weightedchecksum(file2);

myfile2.precision(37);

myfile2 << wchecksum << " " << result << "\n";

}while (!myfile1.eof());

myfile1.close();

myfile2.close();

system("pause");

exit(0);



} else if (choice=='3') {



MTRand mtrand1;

// Ask user for length of data file.

cout << "Please enter length of counter files.\n";

cin >> filesize1;



cout << "What weak check-sum are we exploring today?\n";

cin >> cksum;



cout << "What is the extension of the found files. Include the .\n";

cin >> filextension;



cout << "How many results are we looking for.\n";

cin >> myresults;



// Calulate outmany bits needed to calulate this length.

howmanypositions = -1;

count1 = 1;

count2 = 0;

do

{

count2 = count2 + count1;

howmanypositions++;

count1 = count1 * 2;

}while(count2 < filesize1);

count1 = count1 / 2;

startposition = count1; // This will be the highest unit in bits that we can. We start from high and goto low.



// create memory array to hold bits

int bitarray[howmanypositions];



// open devrand and get its file size.

file1="devrand.bin";

filesize2 = filesize(file1);



// open file

fstream myfile1(file1.c_str(), ios::in
ios::binary);

if (!myfile1)

{

myfile1.close();

cout << "Error in line 496.\n";

system("pause");

exit(1);

}



// open counter file.



file2="counter.bin";



// Create the counter file.

runme = createcounterfile(file2);



// open more opening counter file.

fstream myfile2(file2.c_str(), ios::out
ios::in
ios::binary);

if (!myfile2)

{

myfile2.close();

cout << "Error in line 507.\n";

system("pause");

exit(1);

}



// Devrand file position. We can not reset it.

count1 = -1;



// From HERE ARE WE REPEAT THIS OVER AND OVER AGAIN. THIS DOWN HERE IS WHERE THE ACTION IS.

do

{

// copy devrand to counter file.

count2 = -1;

checksum = 0;

do

{

// Setting file position

count1++;

if (count1 == filesize2 - 1)

{

cout << "Device Rand is empty.\n";

myfile1.close();

myfile2.close();

system("del counter.bin");

system("pause");

exit(0);

}



// reading devrand

myfile1.seekg(count1);

myfile1.read( reinterpret_cast
( &buffer ),1);

begin1 = myfile1.tellg();

byte1 = (int)buffer;



count2++;

//writting counter file

buffer = (unsigned char)byte1;

myfile2.seekp(count2);

myfile2.write( reinterpret_cast
( &buffer ),1);

begin2 = myfile2.tellp();



// get weak checksum of counter file



}while(count2 < filesize1 - 1);



// Getting checksum of counter file.

checksum = weakchecksum(file2);

line661:

// read devrand and fill up bit buffer.

do // This is where we use device rand to get a random number nad bring file into check-sum range.

{

count2 = -1; // position in bit buffer;

do

{

// Setting file position

count1++; // DONT RESET THIS.

if (count1 == filesize2 - 1)

{

cout << "Device Rand is empty.\n";

myfile1.close();

myfile2.close();

system("del counter.bin");

system("pause");

exit(0);

}



// reading devrand

myfile1.seekg(count1);

myfile1.read( reinterpret_cast
( &buffer ),1);

begin1 = myfile1.tellg();

byte1 = (int)buffer;



bitpos = 128; // REPLACE THIS WITH SHIFTING THE BITS FROM THE BYTES INTO THE BUFFER LATER.

do

{

count2++;

if (byte1 >= bitpos)

{

bitarray[count2] = 1;

byte1 = byte1 - bitpos;

goto line595;

}

if (byte1 < bitpos)

{

bitarray[count2] = 0;

}

line595:

if (bitpos == 0)

{

break;

}



bitpos = bitpos / 2;

if (count2 == howmanypositions)

{

break;

}



} while(byte1 != 0);

if (count2 == howmanypositions)

{

break;

}



} while(count2 < howmanypositions);



count2 = -1;

randomnumber = 0;

bitposition = startposition;

do // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< This loop has to be checked real hard but logic here will work.

{

count2++;

bitnum = bitarray[count2];

if (bitnum == 1)

{

randomnumber = randomnumber + bitposition;

}

if (randomnumber > filesize1 - 1)

{

randomnumber = randomnumber - bitposition;

break;

}

bitposition = bitposition / 2;



}while(count2 < howmanypositions);



if (randomnumber > filesize1 - 1)

{

randomnumber = mtrand1.randInt(filesize1 - 1);

}



// using file position take counter file down in size or counter file up in size.

if (cksum > checksum)

{

// read byte at random position from file

myfile2.seekg(randomnumber);

myfile2.read( reinterpret_cast
( &buffer ),1);

begin2 = myfile2.tellg();

byte1 = (int)buffer;



// if can add to byte

if (byte1 < 255)

{

checksum = checksum - byte1;

byte1 = byte1 + 1;

checksum = checksum + byte1;

}



//writting counter file

buffer = (unsigned char)byte1;

myfile2.seekp(randomnumber);

myfile2.write( reinterpret_cast
( &buffer ),1);

begin2 = myfile2.tellp();

// write byte back to file.

}



if (cksum < checksum)

{

// read byte at random position from file

myfile2.seekg(randomnumber);

myfile2.read( reinterpret_cast
( &buffer ),1);

begin2 = myfile2.tellg();

byte1 = (int)buffer;



// if can subtract from byte

if (byte1 > 0)

{

checksum = checksum - byte1;

byte1 = byte1 - 1;

checksum = checksum + byte1;

}



//writting counter file

buffer = (unsigned char)byte1;

myfile2.seekp(randomnumber);

myfile2.write( reinterpret_cast
( &buffer ),1);

begin2 = myfile2.tellp();

// write byte back to file.



}



// checksum = weakchecksum(file2); // This slows the program too much only use for testing.



// repeat till counter file created

}while(cksum < checksum

cksum > checksum);



// Put in test loop for check sum

checksum = weakchecksum(file2);

if (checksum < cksum

checksum > cksum)

{

goto line661;

}

// get weighted sum of counter file.

wcksum = weightedchecksum(file2);



// compare weighted sum to ai file. If result found copy it out to found files. create function for this. //

test1 = aicheck(wcksum);



// If AI logic comes back true copy counter file to output file. Will need SS string for this.

// WRITE CODE HERE TO COPY COUNTER FILE OUT TO WITH EXTENSIONS.

if (test1 == 1)

{

variablename++;

std::stringstream ss;

ss << variablename;

ss >> file3;

file3 = file3 + filextension;



// open file1

fstream myfile3(file3.c_str(), ios::out
ios::binary);

if (!myfile1)

{

myfile3.close();

cout << "Failed to read file three.\n";

system("pause");

exit(1);

}



count2 = -1;

do

{

count2++;

myfile2.seekg(count2);

myfile2.read( reinterpret_cast
( &buffer ),1);

begin2 = myfile2.tellg();

byte1 = (int)buffer;



buffer = (unsigned char)byte1;

myfile3.seekp(count2);

myfile3.write( reinterpret_cast
( &buffer ),1);

begin3 = myfile3.tellp();



}while (count2 < filesize1 - 1);

myfile3.close();

}



// PUT REPEAT COMMAND HERE. WE MADE A NOTE AT THE TOP FOR THIS.

}while(variablename < myresults);// Bull shit to make this run forever. Let error up above catch device rand empty to end this. Or put in lock file later.

cout << "The program has finished.\n";

system("pause");

exit(0); // Just in case we get this far shut this program down. yeah, leave this in or choice 3 can bleed in to choice 4.





} else if (choice=='4') {



MTRand mtrand1;

// Ask user for length of data file.

cout << "Please enter length of counter files.\n";

cin >> filesize1;



cout << "What weak check-sum are we exploring today?\n";

cin >> cksum;



cout << "What is the extension of the found files. Include the .\n";

cin >> filextension;



cout << "How many results are we looking for.\n";

cin >> myresults;



cout << "Please carefully enter the weighted check-sum you are looking for.\n";

cin >> wchecksum;



// Calulate outmany bits needed to calulate this length.

howmanypositions = -1;

count1 = 1;

count2 = 0;

do

{

count2 = count2 + count1;

howmanypositions++;

count1 = count1 * 2;

}while(count2 < filesize1);

count1 = count1 / 2;

startposition = count1; // This will be the highest unit in bits that we can. We start from high and goto low.



// create memory array to hold bits

int bitarray[howmanypositions];



// open devrand and get its file size.

file1="devrand.bin";

filesize2 = filesize(file1);



// open file

fstream myfile1(file1.c_str(), ios::in
ios::binary);

if (!myfile1)

{

myfile1.close();

cout << "Error in line 496.\n";

system("pause");

exit(1);

}



// open counter file.



file2="counter.bin";



// Create the counter file.

runme = createcounterfile(file2);



// open more opening counter file.

fstream myfile2(file2.c_str(), ios::out
ios::in
ios::binary);

if (!myfile2)

{

myfile2.close();

cout << "Error in line 507.\n";

system("pause");

exit(1);

}



// Devrand file position. We can not reset it.

count1 = -1;



// From HERE ARE WE REPEAT THIS OVER AND OVER AGAIN. THIS DOWN HERE IS WHERE THE ACTION IS.

do

{

// copy devrand to counter file.

count2 = -1;

checksum = 0;

do

{

// Setting file position

count1++;

if (count1 == filesize2 - 1)

{

cout << "Device Rand is empty.\n";

myfile1.close();

myfile2.close();

system("del counter.bin");

system("pause");

exit(0);

}



// reading devrand

myfile1.seekg(count1);

myfile1.read( reinterpret_cast
( &buffer ),1);

begin1 = myfile1.tellg();

byte1 = (int)buffer;



count2++;

//writting counter file

buffer = (unsigned char)byte1;

myfile2.seekp(count2);

myfile2.write( reinterpret_cast
( &buffer ),1);

begin2 = myfile2.tellp();



// get weak checksum of counter file



}while(count2 < filesize1 - 1);



// Getting checksum of counter file.

checksum = weakchecksum(file2);

line1242:

// read devrand and fill up bit buffer.

do // This is where we use device rand to get a random number nad bring file into check-sum range.

{

count2 = -1; // position in bit buffer;

do

{

// Setting file position

count1++; // DONT RESET THIS.

if (count1 == filesize2 - 1)

{

cout << "Device Rand is empty.\n";

myfile1.close();

myfile2.close();

system("del counter.bin");

system("pause");

exit(0);

}



// reading devrand

myfile1.seekg(count1);

myfile1.read( reinterpret_cast
( &buffer ),1);

begin1 = myfile1.tellg();

byte1 = (int)buffer;



bitpos = 128; // REPLACE THIS WITH SHIFTING THE BITS FROM THE BYTES INTO THE BUFFER LATER.

do

{

count2++;

if (byte1 >= bitpos)

{

bitarray[count2] = 1;

byte1 = byte1 - bitpos;

goto line1281;

}

if (byte1 < bitpos)

{

bitarray[count2] = 0;

}

line1281:

if (bitpos == 0)

{

break;

}



bitpos = bitpos / 2;

if (count2 == howmanypositions)

{

break;

}



} while(byte1 != 0);

if (count2 == howmanypositions)

{

break;

}



} while(count2 < howmanypositions);



count2 = -1;

randomnumber = 0;

bitposition = startposition;

do // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< This loop has to be checked real hard but logic here will work.

{

count2++;

bitnum = bitarray[count2];

if (bitnum == 1)

{

randomnumber = randomnumber + bitposition;

}

if (randomnumber > filesize1 - 1)

{

randomnumber = randomnumber - bitposition;

break;

}

bitposition = bitposition / 2;



}while(count2 < howmanypositions);



if (randomnumber > filesize1 - 1)

{

randomnumber = mtrand1.randInt(filesize1 - 1);

}



// using file position take counter file down in size or counter file up in size. /////////////// <<<<<<<<<<<<<<<<<<<<<<<< update checksum.

if (cksum > checksum)

{

// read byte at random position from file

myfile2.seekg(randomnumber);

myfile2.read( reinterpret_cast
( &buffer ),1);

begin2 = myfile2.tellg();

byte1 = (int)buffer;



// if can add to byte

if (byte1 < 255)

{

checksum = checksum - byte1;

byte1 = byte1 + 1;

checksum = checksum + byte1;

}



//writting counter file

buffer = (unsigned char)byte1;

myfile2.seekp(randomnumber);

myfile2.write( reinterpret_cast
( &buffer ),1);

begin2 = myfile2.tellp();

// write byte back to file.

}



if (cksum < checksum)

{

// read byte at random position from file

myfile2.seekg(randomnumber);

myfile2.read( reinterpret_cast
( &buffer ),1);

begin2 = myfile2.tellg();

byte1 = (int)buffer;



// if can subtract from byte

if (byte1 > 0)

{

checksum = checksum - byte1;

byte1 = byte1 - 1;

checksum = checksum + byte1;

}



//writting counter file

buffer = (unsigned char)byte1;

myfile2.seekp(randomnumber);

myfile2.write( reinterpret_cast
( &buffer ),1);

begin2 = myfile2.tellp();

// write byte back to file.



}



// checksum = weakchecksum(file2); // This slows the program too much only use for testing.



// repeat till counter file created

}while(cksum < checksum

cksum > checksum);



// Put in test loop for check sum

checksum = weakchecksum(file2);

if (checksum < cksum

checksum > cksum)

{

goto line1242;

}

// get weighted sum of counter file.

wcksum = weightedchecksum(file2);



// compare weighted sum to ai file. If result found copy it out to found files. create function for this. //

test1 = compareweightedsums(wchecksum, wcksum);



// WRITE CODE HERE TO COPY COUNTER FILE OUT TO WITH EXTENSIONS.

if (test1 == 0)

{

variablename++;

std::stringstream ss;

ss << variablename;

ss >> file3;

file3 = file3 + filextension;



// open file1

fstream myfile3(file3.c_str(), ios::out
ios::binary);

if (!myfile1)

{

myfile3.close();

cout << "Failed to read file three.\n";

system("pause");

exit(1);

}



count2 = -1;

do

{

count2++;

myfile2.seekg(count2);

myfile2.read( reinterpret_cast
( &buffer ),1);

begin2 = myfile2.tellg();

byte1 = (int)buffer;



buffer = (unsigned char)byte1;

myfile3.seekp(count2);

myfile3.write( reinterpret_cast
( &buffer ),1);

begin3 = myfile3.tellp();



}while (count2 < filesize1 - 1);

myfile3.close();

}



// PUT REPEAT COMMAND HERE. WE MADE A NOTE AT THE TOP FOR THIS.

}while(variablename < myresults);// Bull shit to make this run forever. Let error up above catch device rand empty to end this. Or put in lock file later.

cout << "The program has finished.\n";

system("pause");

exit(0); // Just in case we get this far shut this program down. yeah, leave this in or choice 3 can bleed in to choice 4.



} else if (choice=='5') {



minbyte = 0;

maxbyte = 255;

cout << "Enter name of file.\n";

cin >> file1;

cout << "You entered " << file1 << "\n";

cout << "Enter weak check-sum.\n";

cin >> cksum;

cout << "You entered " << cksum << "\n";

cout << "Enter file size.\n";

cin >> filesize1;

cout << "You entered " << filesize1 << "\n";

runme = createcounterfile(file1);

runme = createchecksum(file1, cksum, filesize1, minbyte, maxbyte);

cout << "FILE CREATED.\n";

system("pause");

exit(0);



} else {



// if we got this far, the response was not valid



cout << "Good bye." << "\n";

system("pause");

exit(0);



}





}