Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
guns-vip
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
chenjunxiong
guns-vip
Commits
ec2728d7
Commit
ec2728d7
authored
Aug 24, 2017
by
stylefeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改生成随机字符串的方法
parent
61310256
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
43 deletions
+19
-43
guns-admin/src/main/java/com/stylefeng/guns/core/shiro/ShiroKit.java
+2
-9
guns-core/src/main/java/com/stylefeng/guns/core/util/ToolUtil.java
+17
-34
No files found.
guns-admin/src/main/java/com/stylefeng/guns/core/shiro/ShiroKit.java
View file @
ec2728d7
...
@@ -17,6 +17,7 @@ package com.stylefeng.guns.core.shiro;
...
@@ -17,6 +17,7 @@ package com.stylefeng.guns.core.shiro;
import
com.stylefeng.guns.common.constant.Const
;
import
com.stylefeng.guns.common.constant.Const
;
import
com.stylefeng.guns.common.constant.factory.ConstantFactory
;
import
com.stylefeng.guns.common.constant.factory.ConstantFactory
;
import
com.stylefeng.guns.core.util.ToolUtil
;
import
org.apache.shiro.SecurityUtils
;
import
org.apache.shiro.SecurityUtils
;
import
org.apache.shiro.crypto.hash.Md5Hash
;
import
org.apache.shiro.crypto.hash.Md5Hash
;
import
org.apache.shiro.crypto.hash.SimpleHash
;
import
org.apache.shiro.crypto.hash.SimpleHash
;
...
@@ -25,7 +26,6 @@ import org.apache.shiro.subject.Subject;
...
@@ -25,7 +26,6 @@ import org.apache.shiro.subject.Subject;
import
org.apache.shiro.util.ByteSource
;
import
org.apache.shiro.util.ByteSource
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Random
;
/**
/**
* shiro工具类
* shiro工具类
...
@@ -64,14 +64,7 @@ public class ShiroKit {
...
@@ -64,14 +64,7 @@ public class ShiroKit {
* @return
* @return
*/
*/
public
static
String
getRandomSalt
(
int
length
)
{
public
static
String
getRandomSalt
(
int
length
)
{
String
base
=
"abcdefghijklmnopqrstuvwxyz0123456789"
;
return
ToolUtil
.
getRandomString
(
length
);
Random
random
=
new
Random
();
StringBuffer
sb
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
int
number
=
random
.
nextInt
(
base
.
length
());
sb
.
append
(
base
.
charAt
(
number
));
}
return
sb
.
toString
();
}
}
/**
/**
...
...
guns-core/src/main/java/com/stylefeng/guns/core/util/ToolUtil.java
View file @
ec2728d7
...
@@ -28,6 +28,23 @@ import java.util.Map.Entry;
...
@@ -28,6 +28,23 @@ import java.util.Map.Entry;
* 高频方法集合类
* 高频方法集合类
*/
*/
public
class
ToolUtil
{
public
class
ToolUtil
{
/**
* 获取随机位数的字符串
*
* @author fengshuonan
* @Date 2017/8/24 14:09
*/
public
static
String
getRandomString
(
int
length
)
{
String
base
=
"abcdefghijklmnopqrstuvwxyz0123456789"
;
Random
random
=
new
Random
();
StringBuffer
sb
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
int
number
=
random
.
nextInt
(
base
.
length
());
sb
.
append
(
base
.
charAt
(
number
));
}
return
sb
.
toString
();
}
/**
/**
* 判断一个对象是否是时间类型
* 判断一个对象是否是时间类型
...
@@ -65,40 +82,6 @@ public class ToolUtil {
...
@@ -65,40 +82,6 @@ public class ToolUtil {
}
}
/**
/**
* @Description 主键id
* @author fengshuonan
*/
public
static
String
getUid
()
{
return
getRandomNum
();
}
/**
* @Description 随机数字
* @author fengshuonan
*/
public
static
String
getRandomNum
()
{
return
Calendar
.
getInstance
().
getTimeInMillis
()
+
generateCellPhoneValNum
();
}
/**
* @Description 获取电话号码
* @author fengshuonan
*/
public
static
String
generateCellPhoneValNum
()
{
String
[]
beforeShuffle
=
new
String
[]{
"1"
,
"2"
,
"3"
,
"4"
,
"5"
,
"6"
,
"7"
,
"8"
,
"9"
,
"0"
};
List
<
String
>
list
=
Arrays
.
asList
(
beforeShuffle
);
Collections
.
shuffle
(
list
);
StringBuilder
buffer
=
new
StringBuilder
();
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
buffer
.
append
(
list
.
get
(
i
));
}
String
afterShuffle
=
buffer
.
toString
();
String
result
=
afterShuffle
.
substring
(
3
,
9
);
return
result
;
}
/**
* 比较两个对象是否相等。<br>
* 比较两个对象是否相等。<br>
* 相同的条件有两个,满足其一即可:<br>
* 相同的条件有两个,满足其一即可:<br>
* 1. obj1 == null && obj2 == null; 2. obj1.equals(obj2)
* 1. obj1 == null && obj2 == null; 2. obj1.equals(obj2)
...
...
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