Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qa-platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
QA
qa-platform
Commits
03e9ccd0
Commit
03e9ccd0
authored
Jul 29, 2021
by
黎博
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
暂时提交
parent
ddf60d4f
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
137 additions
and
31 deletions
+137
-31
AESUtil.java
src/main/java/cn/qg/qaplatform/encrypt/kdsp/AESUtil.java
+10
-10
Purchase.java
src/main/java/cn/qg/qaplatform/process/Purchase.java
+127
-21
No files found.
src/main/java/cn/qg/qaplatform/encrypt/kdsp/AESUtil.java
View file @
03e9ccd0
...
...
@@ -30,37 +30,37 @@ public class AESUtil {
// 加密
public
static
String
encryptToBase64
(
String
sSrc
,
String
sKey
)
throws
Exception
{
if
(
sKey
==
null
)
{
System
.
out
.
print
(
"Key为空null"
);
//
System.out.print("Key为空null");
return
null
;
}
// 判断Key是否为16位
if
(
sKey
.
length
()
!=
16
)
{
System
.
out
.
println
(
sKey
);
System
.
out
.
print
(
"Key长度不是16位"
);
//
System.out.println(sKey);
//
System.out.print("Key长度不是16位");
return
null
;
}
byte
[]
raw
=
sKey
.
getBytes
(
ConfigureEncryptAndDecrypt
.
CHAR_ENCODING
);
byte
[]
raw
=
sKey
.
getBytes
();
for
(
byte
b
:
raw
)
{
System
.
out
.
println
(
"======"
+
b
);
//
System.out.println("======" + b);
}
SecretKeySpec
skeySpec
=
new
SecretKeySpec
(
raw
,
"AES"
);
Cipher
cipher
=
Cipher
.
getInstance
(
ConfigureEncryptAndDecrypt
.
AES_ALGORITHM
);
cipher
.
init
(
Cipher
.
ENCRYPT_MODE
,
skeySpec
);
byte
[]
encrypted
=
cipher
.
doFinal
(
sSrc
.
getBytes
(
ConfigureEncryptAndDecrypt
.
CHAR_ENCODING
));
cipher
.
init
(
Cipher
.
ENCRYPT_MODE
,
skeySpec
,
new
IvParameterSpec
(
raw
)
);
byte
[]
encrypted
=
cipher
.
doFinal
(
sSrc
.
getBytes
());
// 此处使用BASE64做转码功能,同时能起到2次加密的作用。
return
new
String
(
Base64
.
getEncoder
().
encode
(
encrypted
)
,
ConfigureEncryptAndDecrypt
.
CHAR_ENCODING
);
return
new
String
(
Base64
.
getEncoder
().
encode
(
encrypted
));
}
// 解密
public
static
String
decryptFromBase64
(
String
sSrc
,
String
sKey
)
throws
Exception
{
// 判断Key是否正确
if
(
sKey
==
null
)
{
System
.
out
.
print
(
"Key为空null"
);
//
System.out.print("Key为空null");
return
null
;
}
// 判断Key是否为16位
if
(
sKey
.
length
()
!=
16
)
{
System
.
out
.
print
(
"Key长度不是16位"
);
//
System.out.print("Key长度不是16位");
return
null
;
}
// byte[] raw = sKey.getBytes(ConfigureEncryptAndDecrypt.CHAR_ENCODING);
...
...
src/main/java/cn/qg/qaplatform/process/Purchase.java
View file @
03e9ccd0
This diff is collapsed.
Click to expand it.
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