My program tries to hash the file Passwords.txt line by line. However, everytime it does this, all the hash values are incorrect.
void Rainbow::generateTable(string filename)
{
//noOfLines=0;
//bitsToRemove=0;
ifstream myfile("Passwords.txt");
if (myfile)
{
string line;
while (getline(myfile, line))
{
noOfLines++;
}
}
cout << "File is " << noOfLines << " lines long!" << endl;
toRoundUp = log2(noOfLines);
cout << "toRoundUp is " << toRoundUp << endl;
bitsToRemove = ceil(toRoundUp);
cout << "bitsToRemove is " << bitsToRemove << endl;
//myfile.close();
ifstream file("Passwords.txt");
string myline;
if (file.is_open())
{
while (getline(file,myline))
{
cout << md5(myline) << endl;
}
}
displayMenu();
}
However, when I attempt something like this : the hash value is correct
cout << md5("one") << endl;
The contents of Passwords.txt are as follows :
one
two
three
four
five
six
seven
eight
nine
ten
eleven
twelve
thirteen
fourteen
fifteen
sixteen
seventeen
eighteen
nineteen
twenty
These are the hash values output by my program :
945da772b285bb656550d0c2b94ef80c
9d6ec883255ab3527cd340baad797de5
e119d725f6a7b5413a61da21e7232cd5
31897146a8acc1eede32b7cbf4280f86
d97ee990314c796d0cfbedf39dc9d716
b27f9179c0570da135ec7c7f71c06692
b5e416cbaa6b63b46bf6975b2f365bfe
684349fb14f1cd243d91699a03c00b00
67ed2e62351f8e26e2ba17c30075f8be
41be321de3beb1474b2281bbbe4c8115
59bb31725256bd2af6d0b45d6372ff7a
ac573bd3385c4c0a19d5998bd16b3c0a
aae690fe1db712f89101e6665eccdb4a
93cfff3ce14123aa984447d33cd7fbe4
f35aa54743fa6bb0b8a319e55f8830ae
f516ed17f1fefe016cb3a3a398745682
f81da1a9d89b53a89fc71113ff9da7dd
aac5308f9cd346f9a11b9ff510ebd355
5178aa7f04124a2b930aa02abd9dc7f1
067636f2e9b0852519f85c2a33782b00
Any help is very much appreciated!
As @Biffen mentioned, creating a file with nano and doing so via the Ubuntu GUI causes differences in the EOLs. As such, all i need to do was discard the existing file and create an "identical" one via the Ubuntu GUI.