package com.city.util;
import java.util.Date;
import java.util.Random;
import org.junit.Test;
/**
* @author wangxinying 2012-10-19 下午10:49:00
*生成随机的动态密码和静态密码
*/
public class RandomPass {
private static char[] constant=
{'0','1','2','3','4','5','6','7','8','9',
'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
private Boolean falg;
// @Test
public String getPass(int length){
StringBuilder value=new StringBuilder();
Random dom=new Random();
for(int i=0;i<length;i++){
// dom.nextInt(i);
value.append(constant[dom.nextInt(constant.length)]);
}
System.out.println(value);
return value.toString();
}
public Boolean validdate(long datetime){
falg=false;
//date 表示5分钟
long date= 5*60*1000;
long time= new Date().getTime();
if(time-datetime<=date){
falg=true;
}
return falg;
}
public String createtoken(String userid, String password, String uid){
//组成一个map 然后base64编码
return null;
}
public static void main(String[] args) {
RandomPass s=new RandomPass();
String str= s.getPass(6);
System.out.println(str);
}
}