public class SecretKeyCreateUtil {
/**
* 产生密钥信息
* 采用安全的生成随机数方法(SecureRandom)
* @throws IOException
* @throws NoSuchAlgorithmException
*/
public static String createSecretKey() throws IOException, NoSuchAlgorithmException {
final String base = "qwertyuiopasdfghjklzxcvbnm1234567890";
SecureRandom secureRandom=SecureRandom.getInstance("SHA1PRNG");
StringBuffer stringBuffer = new StringBuffer();
for (int i = 0; i < 10; i++) {
int number = sRandom.nextInt(base.length());
sb.append(base.charAt(number));
}
return sb.toString();
}
}
/**
* 产生密钥信息
* 采用安全的生成随机数方法(SecureRandom)
* @throws IOException
* @throws NoSuchAlgorithmException
*/
public static String createSecretKey() throws IOException, NoSuchAlgorithmException {
final String base = "qwertyuiopasdfghjklzxcvbnm1234567890";
SecureRandom secureRandom=SecureRandom.getInstance("SHA1PRNG");
StringBuffer stringBuffer = new StringBuffer();
for (int i = 0; i < 10; i++) {
int number = sRandom.nextInt(base.length());
sb.append(base.charAt(number));
}
return sb.toString();
}
}