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
8df3226a
Commit
8df3226a
authored
Nov 18, 2020
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改实体位置
parent
02ebe5c3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
3 deletions
+5
-3
RsaHelper.java
.../src/main/java/com/yanzuoguang/util/helper/RsaHelper.java
+2
-1
TestRsa.java
yzg-util-base/src/test/java/helper/TestRsa.java
+3
-2
No files found.
yzg-util-base/src/main/java/com/yanzuoguang/util/helper/RsaHelper.java
View file @
8df3226a
...
...
@@ -79,10 +79,11 @@ public final class RsaHelper {
keyPairGen
.
initialize
(
KEYPAIR_LEN
);
KeyPair
keyPair
=
keyPairGen
.
generateKeyPair
();
RSAPublicKey
rsaPublicKey
=
(
RSAPublicKey
)
keyPair
.
getPublic
();
RSAPrivateKey
rsaPrivateKey
=
(
RSAPrivateKey
)
keyPair
.
getPrivate
();
byte
[]
keyBs
=
rsaPublicKey
.
getEncoded
();
String
publicKey
=
encodeBase64
(
keyBs
);
logger
.
info
(
"生成的公钥:\t{}"
,
publicKey
);
RSAPrivateKey
rsaPrivateKey
=
(
RSAPrivateKey
)
keyPair
.
getPrivate
();
keyBs
=
rsaPrivateKey
.
getEncoded
();
String
privateKey
=
encodeBase64
(
keyBs
);
logger
.
info
(
"生成的私钥:\t{}"
,
privateKey
);
...
...
yzg-util-base/src/test/java/helper/TestRsa.java
View file @
8df3226a
...
...
@@ -22,9 +22,10 @@ public class TestRsa {
}
String
from
=
sb
.
toString
();
String
value
=
RsaHelper
.
encryptionByPublicKey
(
from
,
publicKey
);
String
result
=
RsaHelper
.
decryptionByPrivateKey
(
value
,
privateKey
);
String
temp
=
RsaHelper
.
encryptionByPublicKey
(
from
,
publicKey
);
String
result
=
RsaHelper
.
decryptionByPrivateKey
(
temp
,
privateKey
);
System
.
out
.
println
(
from
);
System
.
out
.
println
(
result
);
System
.
out
.
println
(
temp
);
}
}
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