I am developing a Qt application on Windows 8 64 bit OS. I have encountered this weird case where MD5 message digest is just 4 chars long(=32 bit only.) . Except this exceptional input I get 16 chars(=128 bit) message digest string.
MD5 message digest should be fixed length
my code snippet
qDebug()<<"Case 1:=> "; message1="HYQPTPORKTWKJSVIVXHS1.130hello world!"; input.append(message1); output=QCryptographicHash::hash(input,QCryptographicHash::Md5); QString digest1(QString(output).toAscii()); qDebug()<<"md5 string: "<<digest1; qDebug()<<"length :"<<digest1.length(); qDebug()<<"Case 2:=>"; input=""; // clears previous input message2="HYQPTPORKTWKJSVIVXHS1.131hello world!"; // put anything else than message1 input.append(message2); output=QCryptographicHash::hash(input,QCryptographicHash::Md5); QString digest2(QString(output).toAscii()); qDebug()<<"md5 string: "<<digest2; qDebug()<<"length :"<<digest2.length(); Output
Case 1:=> md5 string: ")QÄ" length : 4 // here I'm expecting 16 Case 2:=> md5 string: "X,öéö< Ú4Îu" length : 16 Am I doing something wrong?