Package com.google;
Import Java.security.MessageDigest;
Import java.security.NoSuchAlgorithmException;
/**
* @author CQY13 MD5 Encryption Tool class
*/
public class Md5utils {
/**
* Get MD5 encryption
*
* @param pwd
* Strings that need to be encrypted
* @return string string with strings encrypted
*/
public static string Getpwd (string pwd) {
try {
MessageDigest digest = messagedigest.getinstance ("MD5");
byte[] bs = Digest.digest (Pwd.getbytes ());
String hexstring = "";
for (byte b:bs) {
int temp = b & 255;
if (Temp < && temp >= 0) {
Manually fill in a "0"
hexstring = hexstring + "0" + integer.tohexstring (temp);
} else {
hexstring = hexstring + integer.tohexstring (temp);
}
}
return hexstring;
} catch (NoSuchAlgorithmException e) {
E.printstacktrace ();
}
Return "";
}
/**
* @param args
*/
public static void Main (string[] args) {
String pwd = md5utils.getpwd ("[Email protected]#$..");
System.out.println (PWD);
}
}
MD5 encryption algorithm