Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
m0_37233914
xfg-frame-ddd
提交
d028c9bf
xfg-frame-ddd
项目概览
m0_37233914
/
xfg-frame-ddd
与 Fork 源项目一致
Fork自
KnowledgePlanet / road-map / xfg-frame-ddd
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
xfg-frame-ddd
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
d028c9bf
编写于
11月 29, 2023
作者:
小傅哥
⛹
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
小傅哥,feat:架构的本质之 DDD 架构
上级
d2d08d6a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
65 addition
and
34 deletion
+65
-34
pom.xml
pom.xml
+0
-34
xfg-frame-app/src/test/java/cn/bugstack/xfg/frame/test/AESTest.java
...app/src/test/java/cn/bugstack/xfg/frame/test/AESTest.java
+65
-0
未找到文件。
pom.xml
浏览文件 @
d028c9bf
...
...
@@ -170,40 +170,6 @@
<properties>
<profileActive>
prod
</profileActive>
</properties>
<build>
<plugins>
<plugin>
<artifactId>
maven-enforcer-plugin
</artifactId>
<dependencies>
<dependency>
<groupId>
org.codehaus.mojo
</groupId>
<artifactId>
extra-enforcer-rules
</artifactId>
<version>
1.4
</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>
enforce-banned-dependencies-app
</id>
<phase>
install
</phase>
<goals>
<goal>
enforce
</goal>
</goals>
<configuration>
<rules>
<bannedDependencies>
<searchTransitive>
true
</searchTransitive>
<excludes>
<exclude>
*:*:[,0.0.1)
</exclude>
</excludes>
</bannedDependencies>
</rules>
<fail>
true
</fail>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
...
...
xfg-frame-app/src/test/java/cn/bugstack/xfg/frame/test/AESTest.java
0 → 100644
浏览文件 @
d028c9bf
package
cn.bugstack.xfg.frame.test
;
import
javax.crypto.Cipher
;
import
javax.crypto.spec.IvParameterSpec
;
import
javax.crypto.spec.SecretKeySpec
;
import
java.util.Base64
;
/**
* @author Fuzhengwei bugstack.cn @小傅哥
* @description
* @create 2023-07-18 22:08
*/
public
class
AESTest
{
/**
* 密钥,必须是16位
*/
private
static
final
String
KEY
=
"1143456789abudef"
;
/**
* 偏移量,必须是16位
*/
private
static
final
String
IV
=
"abcdef9806543210"
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
System
.
out
.
println
(
encrypt
(
"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"
));
System
.
out
.
println
(
encrypt
(
""
));
System
.
out
.
println
(
encrypt
(
""
));
System
.
out
.
println
(
encrypt
(
""
));
System
.
out
.
println
(
encrypt
(
""
));
System
.
out
.
println
(
encrypt
(
""
));
System
.
out
.
println
(
encrypt
(
""
));
System
.
out
.
println
(
encrypt
(
""
));
System
.
out
.
println
(
encrypt
(
""
));
System
.
out
.
println
(
encrypt
(
""
));
}
public
static
String
encrypt
(
String
content
)
throws
Exception
{
Cipher
cipher
=
Cipher
.
getInstance
(
"AES/CBC/PKCS5Padding"
);
byte
[]
raw
=
KEY
.
getBytes
();
SecretKeySpec
secretKeySpec
=
new
SecretKeySpec
(
raw
,
"AES"
);
IvParameterSpec
ivParameterSpec
=
new
IvParameterSpec
(
IV
.
getBytes
());
cipher
.
init
(
Cipher
.
ENCRYPT_MODE
,
secretKeySpec
,
ivParameterSpec
);
byte
[]
encrypted
=
cipher
.
doFinal
(
content
.
getBytes
());
return
Base64
.
getEncoder
().
encodeToString
(
encrypted
);
}
/**
* AES解密
*
* @param content 密文
* @return 明文
* @throws Exception 异常
*/
public
String
decrypt
(
String
content
)
throws
Exception
{
Cipher
cipher
=
Cipher
.
getInstance
(
"AES/CBC/PKCS5Padding"
);
byte
[]
raw
=
KEY
.
getBytes
();
SecretKeySpec
secretKeySpec
=
new
SecretKeySpec
(
raw
,
"AES"
);
IvParameterSpec
ivParameterSpec
=
new
IvParameterSpec
(
IV
.
getBytes
());
cipher
.
init
(
Cipher
.
DECRYPT_MODE
,
secretKeySpec
,
ivParameterSpec
);
byte
[]
encrypted
=
Base64
.
getDecoder
().
decode
(
content
);
byte
[]
original
=
cipher
.
doFinal
(
encrypted
);
return
new
String
(
original
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录