Package com. roomsearchtest;
Import java. Security. messagedigest;
Public class md5util {
Public final static string MD5 (string s ){
Char hexdigits [] = {'0', '1', '2', '3', '4 ',
'5', '6', '7', '8', '9 ',
'A', 'B', 'C', 'D', 'E', 'E', 'F '};
Try {
Byte [] btinput = S. getbytes ();
Messagedigest mdinst = messagedigest. getinstance ("MD5 ");
Mdinst. Update (btinput );
Byte [] MD = mdinst. Digest ();
Int J = md. length;
Char STR [] = new char [J * 2];
Int K = 0;
For (INT I = 0; I <j; I ++ ){
Byte byte0 = md [I];
STR [k ++] = hexdigits [byte0 >>> 4 & 0xf];
STR [k ++] = hexdigits [byte0 & 0xf];
}
Return new string (STR );
}
Catch (exception e ){
E. printstacktrace ();
Return NULL;
}
}
Public static void main (string [] ARGs ){
String temp1 = md5util. MD5 ("Zhucheng zhuyun city vine 3 xianshi Villa/Dongjing kettle ");
String temp2 = md5util. MD5 ("tokuai 3 xianshi villa, Zhucheng zhuyun City ");
If (temp1.equals (temp2 ))
{
System. Out. println (temp1 + "OK ");
}
Else
{
System. Out. println (temp1 + "" + temp2 + "false ");
}
}
}