Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gic-enterprise-base
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
base_platform_enterprise
gic-enterprise-base
Commits
83779fca
Commit
83779fca
authored
Aug 09, 2019
by
guojuxing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加随机生成N位数的随机数(字母、数字组成)
parent
9d7a9bd5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
0 deletions
+36
-0
CreatePasswordAutoUtils.java
...ava/com/gic/enterprise/utils/CreatePasswordAutoUtils.java
+36
-0
No files found.
gic-enterprise-base-api/src/main/java/com/gic/enterprise/utils/CreatePasswordAutoUtils.java
0 → 100644
View file @
83779fca
package
com
.
gic
.
enterprise
.
utils
;
import
java.util.Random
;
/**
* 随机生成字母、数字参合的密码
* @ClassName: CreatePasswordAutoUtils
* @Description:
* @author guojuxing
* @date 2019/8/9 4:39 PM
*/
public
class
CreatePasswordAutoUtils
{
/**
* 随机生成字母、数字参合的密码
* @param length 生成多少位数的密码
* @return
*/
public
static
String
getStringRandom
(
int
length
)
{
String
val
=
""
;
Random
random
=
new
Random
();
//length为几位密码
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
String
charOrNum
=
random
.
nextInt
(
2
)
%
2
==
0
?
"char"
:
"num"
;
//输出字母还是数字
if
(
"char"
.
equalsIgnoreCase
(
charOrNum
))
{
//输出是大写字母还是小写字母
int
temp
=
random
.
nextInt
(
2
)
%
2
==
0
?
65
:
97
;
val
+=
(
char
)
(
random
.
nextInt
(
26
)
+
temp
);
}
else
if
(
"num"
.
equalsIgnoreCase
(
charOrNum
))
{
val
+=
String
.
valueOf
(
random
.
nextInt
(
10
));
}
}
return
val
;
}
}
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