Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
Y
yzg-util
Project
Project
Details
Activity
Releases
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
YZG
yzg-util
Commits
d048f8a5
Commit
d048f8a5
authored
Jun 27, 2023
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
表结构修改
parent
10448834
Changes
2
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
308 additions
and
94 deletions
+308
-94
RsaHelper.java
.../src/main/java/com/yanzuoguang/util/helper/RsaHelper.java
+291
-89
TestRsa.java
yzg-util-base/src/test/java/helper/TestRsa.java
+17
-5
No files found.
yzg-util-base/src/main/java/com/yanzuoguang/util/helper/RsaHelper.java
View file @
d048f8a5
This diff is collapsed.
Click to expand it.
yzg-util-base/src/test/java/helper/TestRsa.java
View file @
d048f8a5
...
...
@@ -12,7 +12,7 @@ public class TestRsa {
}
@Test
public
void
testRsa
()
throws
Exception
{
public
void
testRsa
()
{
RsaHelper
.
RsaInfo
rsaInfo
=
RsaHelper
.
generatorRsa
();
testRsaPublicEncode
(
rsaInfo
);
testRsaPrivateEncode
(
rsaInfo
);
...
...
@@ -37,9 +37,15 @@ public class TestRsa {
String
temp
=
RsaHelper
.
encryptionByPublicKey
(
from
,
rsaInfo
.
getPublicKey
());
String
result
=
RsaHelper
.
decryptionByPrivateKey
(
temp
,
rsaInfo
.
getPrivateKey
());
System
.
out
.
println
(
"原字段:"
+
from
);
System
.
out
.
println
(
"公钥加密后字段"
+
temp
);
System
.
out
.
println
(
"私钥解密后字段"
+
result
);
System
.
out
.
println
(
"公钥加密后字段
:
"
+
temp
);
System
.
out
.
println
(
"私钥解密后字段
:
"
+
result
);
Assert
.
assertEquals
(
from
,
result
);
String
rsaTemp
=
RsaHelper
.
encodeRsaValueInfo
(
from
,
rsaInfo
.
getPublicKeyFrom
());
String
rsaResult
=
RsaHelper
.
decodeRsaValueInfo
(
rsaTemp
,
rsaInfo
.
getPrivateKeyFrom
(),
10
*
1000
);
System
.
out
.
println
(
"Json时间公钥加密后字段:"
+
rsaTemp
);
System
.
out
.
println
(
"Json时间私钥解密后字段:"
+
rsaResult
);
Assert
.
assertEquals
(
from
,
rsaResult
);
}
...
...
@@ -53,8 +59,14 @@ public class TestRsa {
String
temp
=
RsaHelper
.
encryptionByPrivateKey
(
from
,
rsaInfo
.
getPrivateKey
());
String
result
=
RsaHelper
.
decryptionByPublicKey
(
temp
,
rsaInfo
.
getPublicKey
());
System
.
out
.
println
(
"原字段:"
+
from
);
System
.
out
.
println
(
"公钥加密后字段"
+
temp
);
System
.
out
.
println
(
"私钥解密后字段"
+
result
);
System
.
out
.
println
(
"公钥加密后字段
:
"
+
temp
);
System
.
out
.
println
(
"私钥解密后字段
:
"
+
result
);
Assert
.
assertEquals
(
from
,
result
);
String
rsaTemp
=
RsaHelper
.
encodeRsaValueInfo
(
from
,
rsaInfo
.
getPrivateKeyFrom
());
String
rsaResult
=
RsaHelper
.
decodeRsaValueInfo
(
rsaTemp
,
rsaInfo
.
getPublicKeyFrom
(),
10
*
1000
);
System
.
out
.
println
(
"Json时间公钥加密后字段:"
+
rsaTemp
);
System
.
out
.
println
(
"Json时间私钥解密后字段:"
+
rsaResult
);
Assert
.
assertEquals
(
from
,
rsaResult
);
}
}
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