Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
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
项目统一框架
amos-boot-biz
Commits
3eda888c
Commit
3eda888c
authored
Apr 02, 2026
by
刘林
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(jg):AESUtil工具类修改
parent
a440d202
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
6 deletions
+50
-6
AESUtil.java
...m/yeejoin/amos/boot/module/common/api/crypto/AESUtil.java
+39
-6
pom.xml
pom.xml
+11
-0
No files found.
amos-boot-system-tzs/amos-boot-module-common/amos-boot-module-common-api/src/main/java/com/yeejoin/amos/boot/module/common/api/crypto/AESUtil.java
View file @
3eda888c
...
...
@@ -17,20 +17,53 @@ public class AESUtil {
aes
=
new
AES
(
mode
,
padding
,
key
,
iv
);
}
private
static
class
AESUtilHolder
{
private
static
final
AESUtil
instance
=
new
AESUtil
(
Mode
.
CBC
,
Padding
.
PKCS5Padding
,
key
.
getBytes
(
StandardCharsets
.
UTF_8
),
iv
.
getBytes
(
StandardCharsets
.
UTF_8
));
}
private
static
volatile
AESUtil
instance
=
null
;
private
static
AESUtil
getInstance
()
{
return
AESUtilHolder
.
instance
;
if
(
instance
==
null
)
{
synchronized
(
AESUtil
.
class
)
{
if
(
instance
==
null
)
{
try
{
instance
=
new
AESUtil
(
Mode
.
CBC
,
Padding
.
PKCS5Padding
,
key
.
getBytes
(
StandardCharsets
.
UTF_8
),
iv
.
getBytes
(
StandardCharsets
.
UTF_8
));
}
catch
(
Exception
e
)
{
// 加密初始化失败,使用空实现
instance
=
new
AESUtil
()
{
protected
String
doEncrypt
(
String
data
)
{
return
data
;
}
protected
String
doDecrypt
(
String
data
)
{
return
data
;
}
};
}
}
}
}
return
instance
;
}
// 空构造函数,用于创建失败时的备用实例
private
AESUtil
()
{
this
.
aes
=
null
;
}
public
static
String
encrypt
(
String
data
)
{
return
getInstance
().
aes
.
encryptBase64
(
data
);
return
getInstance
().
doEncrypt
(
data
);
}
public
static
String
decrypt
(
String
data
)
{
return
getInstance
().
aes
.
decryptStr
(
data
,
StandardCharsets
.
UTF_8
);
return
getInstance
().
doDecrypt
(
data
);
}
// 子类覆盖的方法
protected
String
doEncrypt
(
String
data
)
{
assert
aes
!=
null
;
return
aes
.
encryptBase64
(
data
);
}
protected
String
doDecrypt
(
String
data
)
{
assert
aes
!=
null
;
return
aes
.
decryptStr
(
data
,
StandardCharsets
.
UTF_8
);
}
}
pom.xml
View file @
3eda888c
...
...
@@ -192,6 +192,17 @@
</exclusion>
</exclusions>
</dependency>
<!-- Bouncy Castle 加密库 -->
<dependency>
<groupId>
org.bouncycastle
</groupId>
<artifactId>
bcprov-jdk15on
</artifactId>
<version>
1.68
</version>
</dependency>
<dependency>
<groupId>
org.bouncycastle
</groupId>
<artifactId>
bcpkix-jdk15on
</artifactId>
<version>
1.68
</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
...
...
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