Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gdtel-gztel-school-center
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
吴学德
gdtel-gztel-school-center
Commits
d9fc4ba5
Commit
d9fc4ba5
authored
Jun 11, 2021
by
邝钲钞
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复不安全的随机数问题
parent
70490dce
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
3 deletions
+2
-3
common/src/main/java/com/winsun/utils/RandomUtil.java
+2
-3
No files found.
common/src/main/java/com/winsun/utils/RandomUtil.java
View file @
d9fc4ba5
package
com
.
winsun
.
utils
;
import
java.security.SecureRandom
;
import
java.util.Random
;
/**
* 随机数工具类
...
...
@@ -40,7 +39,7 @@ public class RandomUtil {
public
static
String
RandomNumber
(
int
length
){
String
str
=
"1234567890abcdefghijklmnopqrstuvwxyz"
;
try
{
Random
random
=
new
Random
(
);
SecureRandom
random
=
SecureRandom
.
getInstance
(
"SHA1PRNG"
);
StringBuffer
sb
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
length
;
i
++){
...
...
@@ -64,7 +63,7 @@ public class RandomUtil {
public
static
String
ramdomNum
(
Integer
length
){
String
str
=
"1234567890"
;
try
{
Random
random
=
new
Random
(
);
SecureRandom
random
=
SecureRandom
.
getInstance
(
"SHA1PRNG"
);
StringBuffer
sb
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
length
;
i
++){
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment