I'm trying to implement MD5 in a C++ function, and even though the math is killing me, the real problem is the preprocessing of the data that has to be done before doing the MD5 rounds.
I need to add a "1" bit to the end of my data and then append "0" bits onto my data until LengthInBits = 448 % 512.
Then finally i have to append the length of the unpadded data to the file as a 64-bit little endian integer.
I've got no idea how to manipulate the bits in my data, the smallest type i know of is a char which is guaranteed to be 1 byte (8bit). I've been googling around and i think what i need to use is a Bitfield, amirite?
My question is, how should i declare my bitfield struct? Atm i've got this:
Would this work for what i'm trying to do? Basically i've got a vector full of these BitField structs, and then i was planning to just loop over a file and load it into my vector bit for bit.Code:
char data : 1;
Would this work? Then to add the "1" bit i could do something like this:
This will probably not be the last problem i'm going to have with this, so i hope you guys can be patient with me :)Code:
BF.data = 1; //Is this correct?
vData.push_back(BF); //vData is my vector