Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
Y
YX_IDENT_REFACTORING
Project
Project
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
zhangyusheng
YX_IDENT_REFACTORING
Commits
8e356ca0
Commit
8e356ca0
authored
Oct 16, 2018
by
liboyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
md5加密工具类
parent
8107cedb
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
0 deletions
+46
-0
Md5Utils.java
src/main/java/com/yxproject/start/utils/Md5Utils.java
+46
-0
No files found.
src/main/java/com/yxproject/start/utils/Md5Utils.java
0 → 100644
View file @
8e356ca0
package
com
.
yxproject
.
start
.
utils
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.TimeZone
;
import
java.util.UUID
;
import
org.apache.shiro.crypto.hash.SimpleHash
;
import
org.apache.shiro.util.ByteSource
;
/**
* 工具类
* @author itdragon
*
*/
public
class
Md5Utils
{
private
static
final
String
ALGORITHM_NAME
=
"MD5"
;
private
static
final
Integer
HASH_ITERATIONS
=
1024
;
/**
* 加盐加密的策略非常多,根据实际业务来
*/
public
static
String
entryptPassword
(
String
password
,
String
salt
)
{
Object
md5Password
=
new
SimpleHash
(
ALGORITHM_NAME
,
password
,
ByteSource
.
Util
.
bytes
(
salt
),
HASH_ITERATIONS
);
return
md5Password
.
toString
();
}
public
static
String
getCurrentDateTime
()
{
TimeZone
zone
=
TimeZone
.
getTimeZone
(
"Asia/Beijing"
);
TimeZone
.
setDefault
(
zone
);
SimpleDateFormat
df
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
return
df
.
format
(
new
Date
());
}
public
static
void
main
(
String
[]
args
){
String
salt
=
UUID
.
randomUUID
().
toString
();
String
pass
=
Md5Utils
.
entryptPassword
(
"123456"
,
salt
);
System
.
out
.
println
(
pass
);
System
.
out
.
println
(
salt
);
}
}
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