MessageDigest md =
MessageDigest.getInstance("MD5");
/*This method takes an
array of bytes representing
the message and
adds / passes it to the
MessageDigest object created
above.*/
md.update(passhex.getBytes());
/*This method calculates
the hash function for the
current object and returns
the message digest as a
byte array.*/
byte[] digest = md.digest();
/*Converting the byte
array in to HexString format*/
StringBuffer hexString = new
StringBuffer();
for (int i = 0;i<digest.length;i++){
hexString.append(Integer.toHexString
(0xFF & digest[i]));
}