Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
map-parent
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
常超
map-parent
Commits
9a0eccca
Commit
9a0eccca
authored
Jul 13, 2022
by
yangyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
同步(西藏)
parent
a66ba08e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
0 deletions
+56
-0
common/common_utils/src/main/java/com/founder/commonutils/util/JasyptEncryptorUtils.java
+56
-0
No files found.
common/common_utils/src/main/java/com/founder/commonutils/util/JasyptEncryptorUtils.java
0 → 100644
View file @
9a0eccca
package
com
.
founder
.
commonutils
.
util
;
import
org.jasypt.properties.PropertyValueEncryptionUtils
;
import
org.jasypt.util.text.BasicTextEncryptor
;
public
class
JasyptEncryptorUtils
{
private
static
final
String
salt
=
"lybgeek"
;
private
static
BasicTextEncryptor
basicTextEncryptor
=
new
BasicTextEncryptor
();
static
{
basicTextEncryptor
.
setPassword
(
salt
);
}
private
JasyptEncryptorUtils
(){}
/**
* 明文加密
* @param plaintext
* @return
*/
public
static
String
encode
(
String
plaintext
){
System
.
out
.
println
(
"明文字符串:"
+
plaintext
);
String
ciphertext
=
basicTextEncryptor
.
encrypt
(
plaintext
);
System
.
out
.
println
(
"加密后字符串:"
+
ciphertext
);
return
ciphertext
;
}
/**
* 解密
* @param ciphertext
* @return
*/
public
static
String
decode
(
String
ciphertext
){
System
.
out
.
println
(
"加密字符串:"
+
ciphertext
);
ciphertext
=
"ENC("
+
ciphertext
+
")"
;
if
(
PropertyValueEncryptionUtils
.
isEncryptedValue
(
ciphertext
)){
String
plaintext
=
PropertyValueEncryptionUtils
.
decrypt
(
ciphertext
,
basicTextEncryptor
);
System
.
out
.
println
(
"解密后的字符串:"
+
plaintext
);
return
plaintext
;
}
System
.
out
.
println
(
"解密失败"
);
return
""
;
}
/**
* 测试
*/
public
static
void
main
(
String
args
[])
throws
Exception
{
String
test1
=
"XzxtPwd#54"
;
encode
(
test1
);
decode
(
encode
(
test1
));
}
}
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