FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
zstack/utils/src/main/java/org/zstack/utils/SHAUtils.java at master · zstackio/zstack · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
zstackio
/
zstack
Public
Notifications
You must be signed in to change notification settings
Fork
399
Star
1.4k
Code
Issues
163
Pull requests
13
Actions
Projects
Wiki
Security and quality
4
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
zstack
/
utils
/
src
/
main
/
java
/
org
/
zstack
/
utils
/
SHAUtils.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
38 lines (34 loc) · 1.15 KB
Breadcrumbs
zstack
/
utils
/
src
/
main
/
java
/
org
/
zstack
/
utils
/
SHAUtils.java
Copy path
File metadata and controls
38 lines (34 loc) · 1.15 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package
org
.
zstack
.
utils
;
import
org
.
apache
.
commons
.
codec
.
digest
.
DigestUtils
;
import
java
.
io
.
FileInputStream
;
import
java
.
io
.
IOException
;
import
java
.
io
.
UnsupportedEncodingException
;
import
java
.
math
.
BigInteger
;
import
java
.
nio
.
file
.
Files
;
import
java
.
nio
.
file
.
Paths
;
import
java
.
security
.
MessageDigest
;
import
java
.
security
.
NoSuchAlgorithmException
;
/**
* Created by lining on 2019/9/4.
*/
public
class
SHAUtils
{
public
static
String
encrypt
(
String
input
,
String
algorithm
) {
try
{
MessageDigest
md
=
MessageDigest
.
getInstance
(
algorithm
);
md
.
reset
();
md
.
update
(
input
.
getBytes
(
"utf8"
));
BigInteger
bigInteger
=
new
BigInteger
(
1
,
md
.
digest
());
return
String
.
format
(
"%0128x"
,
bigInteger
);
}
catch
(
NoSuchAlgorithmException
|
UnsupportedEncodingException
e
) {
throw
new
RuntimeException
(
e
);
}
}
public
static
String
getFileMd5sum
(
String
filePath
) {
try
{
FileInputStream
srcIn
=
new
FileInputStream
(
filePath
);
return
DigestUtils
.
md5Hex
(
srcIn
);
}
catch
(
Exception
e
) {
throw
new
RuntimeException
(
e
);
}
}
}
Back
|
FazBrowse Home
|
New Git URL