//验证码有效期 5分钟
public boolean getMsgTime() {
if(!((new Date().getTime()-msgTime)>300000)){
return true;
}
return false;
}
//短信验证码有效期为1分钟
public boolean getCurrentTime() {
if(!((new Date().getTime()-msgTime)>60000)){
return true;
}
return false;
}
public String getMessage() {
return message;
}
public void setMessage() {
this.message = getRandomString(6);
}
public String getRandomString(int length) { //length表示生成字符串的长度
String base = "0123456789qweasdzxcrtyuioplkjhgfvbnm";
Random random = new Random();
StringBuffer sb = new StringBuffer();
for (int i = 0; i < length; i++) {
int number = random.nextInt(base.length());
sb.append(base.charAt(number));
}
return sb.toString();
}
随机验证码的生成
最新推荐文章于 2021-07-06 17:28:17 发布