MD5加密工具类
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.Arrays;
/**
* MD5加密及密码验证
*/
public class MyMD5Util {
private static final String HEX_NUMS_STR="0123456789ABCDEF";
private static final Integer SALT_LENGTH = 12;
/**
* 测试方法
*/
public static void main(String[] args) {
//设置密码:123456
String newPwd = "123456";
try{
//生成md5
String newPwdMd5 = MyMD5Util.getEncryptedPwd(newPwd);
System.out.println(newPwdMd5);
//验证密码123是否正确
Boolean flag = MyMD5Util.validPassword("123",newPwdMd5);
//false 密码错误
System.out.println(flag);
}catch (Exception e){
e.printStackTrace();
}
}
/**
* 将16进制字符串转换成字节数组
* &