Commit d9fc4ba5 by 邝钲钞

修复不安全的随机数问题

parent 70490dce
package com.winsun.utils; package com.winsun.utils;
import java.security.SecureRandom; import java.security.SecureRandom;
import java.util.Random;
/** /**
* 随机数工具类 * 随机数工具类
...@@ -40,7 +39,7 @@ public class RandomUtil { ...@@ -40,7 +39,7 @@ public class RandomUtil {
public static String RandomNumber(int length){ public static String RandomNumber(int length){
String str="1234567890abcdefghijklmnopqrstuvwxyz"; String str="1234567890abcdefghijklmnopqrstuvwxyz";
try { try {
Random random=new Random(); SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
StringBuffer sb=new StringBuffer(); StringBuffer sb=new StringBuffer();
for(int i=0;i<length;i++){ for(int i=0;i<length;i++){
...@@ -64,7 +63,7 @@ public class RandomUtil { ...@@ -64,7 +63,7 @@ public class RandomUtil {
public static String ramdomNum(Integer length){ public static String ramdomNum(Integer length){
String str="1234567890"; String str="1234567890";
try{ try{
Random random=new Random(); SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
StringBuffer sb=new StringBuffer(); StringBuffer sb=new StringBuffer();
for(int i=0;i<length;i++){ for(int i=0;i<length;i++){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment