Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xyqb-user2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
head_group
xyqb-user2
Commits
34b3ac53
Commit
34b3ac53
authored
Aug 23, 2019
by
技术部-任文超
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新随机密码生成器
parent
9f069e62
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
10 deletions
+7
-10
PasswordUtil.java
src/main/java/cn/quantgroup/xyqb/util/PasswordUtil.java
+7
-10
No files found.
src/main/java/cn/quantgroup/xyqb/util/PasswordUtil.java
View file @
34b3ac53
...
@@ -22,7 +22,9 @@ public class PasswordUtil {
...
@@ -22,7 +22,9 @@ public class PasswordUtil {
private
static
final
char
[]
PWD_BASE
=
{
private
static
final
char
[]
PWD_BASE
=
{
'a'
,
'b'
,
'c'
,
'd'
,
'e'
,
'f'
,
'g'
,
'h'
,
'i'
,
'j'
,
'k'
,
'a'
,
'b'
,
'c'
,
'd'
,
'e'
,
'f'
,
'g'
,
'h'
,
'i'
,
'j'
,
'k'
,
'l'
,
'm'
,
'n'
,
'o'
,
'p'
,
'q'
,
'r'
,
's'
,
't'
,
'u'
,
'v'
,
'w'
,
'l'
,
'm'
,
'n'
,
'o'
,
'p'
,
'q'
,
'r'
,
's'
,
't'
,
'u'
,
'v'
,
'w'
,
'x'
,
'y'
,
'z'
,
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
'x'
,
'y'
,
'z'
,
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
,
'!'
,
'"'
,
'#'
,
'$'
,
'%'
,
'&'
,
'\''
,
'('
,
')'
,
'*'
,
'+'
,
','
,
'-'
,
'.'
,
'/'
,
':'
,
';'
,
'<'
,
'='
,
'>'
,
'?'
,
'@'
,
'['
,
'\\'
,
']'
,
'^'
,
'_'
,
'`'
,
'{'
,
'|'
,
'}'
,
'~'
};
};
public
final
static
String
MD5WithSalt
(
String
s
){
public
final
static
String
MD5WithSalt
(
String
s
){
...
@@ -63,16 +65,11 @@ public class PasswordUtil {
...
@@ -63,16 +65,11 @@ public class PasswordUtil {
*/
*/
public
static
String
generateRandomPwd
(
int
pwdLen
)
{
public
static
String
generateRandomPwd
(
int
pwdLen
)
{
Preconditions
.
checkArgument
(
pwdLen
>
0
);
Preconditions
.
checkArgument
(
pwdLen
>
0
);
int
pwdMax
=
PWD_BASE
.
length
;
int
i
;
// 生成的随机数
int
count
=
0
;
// 生成的密码的长度
StringBuilder
pwd
=
new
StringBuilder
();
StringBuilder
pwd
=
new
StringBuilder
();
while
(
count
<
pwdLen
)
{
while
(
pwd
.
length
()
<
pwdLen
)
{
i
=
ThreadLocalRandom
.
current
().
nextInt
(
pwdMax
);
// 生成的数最大为36-1
// 随机整数区间: [0, PWD_BASE.length - 1)
if
(
i
>=
0
&&
i
<
PWD_BASE
.
length
)
{
int
index
=
ThreadLocalRandom
.
current
().
nextInt
(
0
,
PWD_BASE
.
length
);
pwd
.
append
(
PWD_BASE
[
i
]);
pwd
.
append
(
PWD_BASE
[
index
]);
count
++;
}
}
}
return
pwd
.
toString
();
return
pwd
.
toString
();
}
}
...
...
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