哪种是生成随机令牌/种子的最佳方式?有什么最新的java库可以做到吗?方法 1 更随机还是方法 2 更随机?这两个哪个更好?
//Method 1:
private static SecureRandom random = new SecureRandom();
public static String generaterandomtoken()
{
String str=new BigInteger(100, random).toString(32);
return str;
}
//Method 2:
private static SecureRandom random = new SecureRandom();
public static String generaterandomtoken()
{
Calendar calendar=Calendar.getInstance();
long millis=calendar.getTimeInMillis();
random.setSeed(millis);
String ran=new BigInteger(100, random).toString(32);
return ran;
}