* context.
*/
-void
+void
MD5::Update(uint8_t const *input, size_t inputLen)
{
unsigned int i, index, partLen;
// the message digest and zeroizing the context.
// Writes to digestRaw
-void
+void
MD5::Final()
{
uint8_t bits[8];
writeToString();
}
-/// Buffer must be 32+1 (nul) = 33 chars long at least
-void
+/// Buffer must be 32+1 (nul) = 33 chars long at least
+void
MD5::writeToString()
{
int pos;
/// Load a file from disk and digest it
// Digests a file and returns the result.
-char*
+char*
MD5::digestFile (char *filename)
{
Init();
-
+
FILE *file;
int len;
unsigned char buffer[1024];
}
/// Digests a byte-array already in memory
-char*
+char*
MD5::digestMemory (uint8_t const * memchunk, size_t len)
{
Init ();
Update (memchunk, len);
Final ();
-
+
return digestChars;
}
// Digests a string and prints the result.
-char*
+char*
MD5::digestString (char const * string)
{
Init ();
return digestChars;
}
-void
+void
MD5::Transform (uint32_t state[4], uint8_t const * block)
{
uint32_t a = state[0], b = state[1], c = state[2], d = state[3], x[16];
-
+
Decode (x, block, 64);
-
+
/* Round 1 */
FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */
FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */
FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
-
+
/* Round 2 */
GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */
GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */
GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */
GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */
GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
-
+
/* Round 3 */
HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */
HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */
/* Encodes input (uint32_t) into output (unsigned char). Assumes len is
* a multiple of 4.
*/
-void
+void
MD5::Encode (uint8_t *output, uint32_t const * input, size_t len)
{
size_t i, j;
* a multiple of 4.
*/
-void
+void
MD5::Decode (uint32_t *output, uint8_t const * input, size_t len)
{
size_t i, j;
-
+
for (i = 0, j = 0; j < len; i++, j += 4)
output[i] = ((uint32_t)input[j]) | (((uint32_t)input[j+1]) << 8) |
(((uint32_t)input[j+2]) << 16) | (((uint32_t)input[j+3]) << 24);