随机生成6位验证码
/**
* 随机生成6位验证码
* @return String
*/
private static String getCode(){
String $ = "$%^_6";
Date date = new Date();
long time = date.getTime();
String pre = time + $;
String s = toMd5(pre);
Random random = new Random();
int i = random.nextInt(s.length() - 6);
return s.substring(i,i+6).toUpperCase();
}
/**
* md5加密
* @param pwd 需加密密码
* @return String
*/
public static String toMd5(String pwd){
String $ = "$%^_5";
String newPwd = pwd + $;
return DigestUtils.md5DigestAsHex(newPwd.getBytes());
}