Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
C
common
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
曲欣亮
common
Commits
04f796bb
Commit
04f796bb
authored
Oct 12, 2018
by
zhangyong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
4ae91871
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
1 deletion
+46
-1
StringUtil.java
src/main/java/com/egolm/common/StringUtil.java
+46
-1
No files found.
src/main/java/com/egolm/common/StringUtil.java
View file @
04f796bb
...
@@ -8,11 +8,15 @@ import java.io.PrintWriter;
...
@@ -8,11 +8,15 @@ import java.io.PrintWriter;
import
java.io.Reader
;
import
java.io.Reader
;
import
java.io.Writer
;
import
java.io.Writer
;
import
java.security.MessageDigest
;
import
java.security.MessageDigest
;
import
java.security.NoSuchAlgorithmException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Collection
;
import
java.util.Comparator
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
java.util.TreeMap
;
import
java.util.UUID
;
import
java.util.UUID
;
import
java.util.regex.Matcher
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
java.util.regex.Pattern
;
...
@@ -1015,5 +1019,46 @@ public class StringUtil {
...
@@ -1015,5 +1019,46 @@ public class StringUtil {
}
}
return
""
;
return
""
;
}
}
/**
*
* @Title: doMD5Sign
* @Description: TODO(这里用一句话描述这个方法的作用)
* @param: @param map
* @param: @return
* @return: String
* @throws
*/
public
static
String
doMD5Sign
(
Map
<
String
,
String
>
map
){
Map
<
String
,
String
>
compMap
=
new
TreeMap
<
String
,
String
>(
new
Comparator
<
String
>()
{
public
int
compare
(
String
obj1
,
String
obj2
)
{
return
obj1
.
compareTo
(
obj2
);
}
});
for
(
Entry
<
String
,
String
>
entry
:
map
.
entrySet
()){
compMap
.
put
(
entry
.
getKey
(),
entry
.
getValue
());
}
StringBuffer
sb
=
new
StringBuffer
();
for
(
Entry
<
String
,
String
>
entry
:
compMap
.
entrySet
()){
sb
.
append
(
"&"
);
sb
.
append
(
entry
.
getKey
());
sb
.
append
(
"="
);
sb
.
append
(
entry
.
getValue
());
}
String
s
=
sb
.
toString
().
substring
(
1
);
byte
[]
secretBytes
=
null
;
try
{
secretBytes
=
MessageDigest
.
getInstance
(
"MD5"
).
digest
(
s
.
getBytes
());
}
catch
(
NoSuchAlgorithmException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
String
sign
=
Hex
.
encodeHexString
(
secretBytes
).
toUpperCase
();
return
sign
;
}
public
static
String
getRandom
(
int
num
){
return
String
.
valueOf
(
Math
.
random
()).
substring
(
2
,
2
+
num
);
}
}
}
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