Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
smart_gov_platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵啸非
smart_gov_platform
Commits
a2ed5c70
Commit
a2ed5c70
authored
Mar 01, 2024
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加国密4加解密接口
parent
f0fd6959
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
502 additions
and
1 deletion
+502
-1
base-manager/src/main/java/com/mortals/xhx/common/utils/RSAUtils.java
.../src/main/java/com/mortals/xhx/common/utils/RSAUtils.java
+44
-0
base-manager/src/main/java/com/mortals/xhx/common/utils/ServicePlatformInvoker.java
.../com/mortals/xhx/common/utils/ServicePlatformInvoker.java
+433
-0
base-manager/src/test/java/com/mortals/httpclient/system/system.http
...r/src/test/java/com/mortals/httpclient/system/system.http
+25
-1
No files found.
base-manager/src/main/java/com/mortals/xhx/common/utils/RSAUtils.java
0 → 100644
View file @
a2ed5c70
package
com.mortals.xhx.common.utils
;
import
org.apache.commons.codec.binary.Hex
;
import
javax.crypto.Cipher
;
import
java.net.URLDecoder
;
import
java.security.KeyFactory
;
import
java.security.PrivateKey
;
import
java.security.spec.PKCS8EncodedKeySpec
;
import
java.util.Base64
;
public
class
RSAUtils
{
// 私钥
private
static
final
String
PRIVATE_KEY
=
"MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBAJJuFUH/4m9H5hCCzxtd9BxpjWlG9gbejqiJpV0XJKaU1V7xDBJasswxPY7Zc15RoxWClPoKPwKrbWKm49dgBJebJq5xd4sLCSbboxRkKxpRiJHMZ4LJjYa5h9Ei9RyfoUzqGHqH4UrDy3m3IwPiP19cIBqoU50shyQf92ZpcGZhAgMBAAECgYEAiadU8pODoUs82x6tZbPALQmJN4PO+wwznfqv6sA74yGdKECAMazz0oMjtGt1SiCCqFD2jcweCftvvELZg3mvNg1V0vRQRD1ZCA8HDp8DXm20d11K3+RX39tR4KgyyM3HsSEhkUDujMxKIpYjyiB5iEtV7Ja9bZ2fROszq+mUIqUCQQDQQf6vWRMLBqfnDcU77vuDGOhXbjkF2ytLxLW3fbKaW3GWvC3n93zPM+mcvWSXgkl448+jFjpMktm1Vn+w+YX3AkEAs/+bbRbod6AcVbLu8C5E44qDRoRpu+LF7Cphp8tlSAIRjm2yGP5acMWGRUtH9MF2QJYPF0PgDzdmUSVqWnCAZwJBALnSuRri4wAKn1SmT+ALfLZcSiyBODZGeppv2ijw6qWahH8YR+ncRaxoyMFHqPMbmM1akJIXqktbGREaLnPOIb8CQQCdJycJaL3Qa98xR4dr9cm5rF6PO96g5w6M8jfO6ztjUkMHymh7f99wpFRlvaN2Y06edyV315ARWPohEPy5N44zAkBlLuDHLm1TkTTAfdlL5r2OcdjpaJYloTdn05Mp3+J+w1zTX8k6Mz8lFZtLUcoMeTfQ9rm/+u2KwxS8NljtSZWH"
;
public
static
String
decode
(
String
encodeStr
,
String
privateKey
)
{
String
decodeStr
=
null
;
try
{
byte
[]
decodeHexStr
=
Hex
.
decodeHex
(
encodeStr
.
toCharArray
());
privateKey
=
privateKey
.
replaceAll
(
" +"
,
"+"
);
byte
[]
privateKeyByte
=
Base64
.
getDecoder
().
decode
(
privateKey
);
PKCS8EncodedKeySpec
privateKeySpec
=
new
PKCS8EncodedKeySpec
(
privateKeyByte
);
KeyFactory
RSAKeyFactory
=
KeyFactory
.
getInstance
(
"RSA"
);
PrivateKey
key
=
RSAKeyFactory
.
generatePrivate
(
privateKeySpec
);
Cipher
cipher
=
Cipher
.
getInstance
(
RSAKeyFactory
.
getAlgorithm
());
cipher
.
init
(
2
,
key
);
byte
[]
bytes
=
cipher
.
doFinal
(
decodeHexStr
);
decodeStr
=
URLDecoder
.
decode
(
new
String
(
bytes
),
"utf-8"
);
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"RSAdecode error: "
+
e
);
}
return
decodeStr
;
}
public
static
void
main
(
String
[]
args
)
{
String
content
=
"130fddec666d6a60ca27ca64e36706d3ee52ee710795636db1fb15a564d2abef1aaa13ab86eaaf534dc4e5e39033f07206a69057519a9a85ecb987c8307dd2514fb6cebcb763c16630cd3941476bb02a96133333c3e8e3d7ebe2fdac0d478d5338d928a1048213b27de330e1c8cd6eea80543f9a12789ab078c4ce96008f242b"
;
System
.
out
.
println
(
RSAUtils
.
decode
(
content
,
PRIVATE_KEY
));
}
}
base-manager/src/main/java/com/mortals/xhx/common/utils/ServicePlatformInvoker.java
0 → 100644
View file @
a2ed5c70
This diff is collapsed.
Click to expand it.
base-manager/src/test/java/com/mortals/httpclient/system/system.http
View file @
a2ed5c70
...
...
@@ -195,4 +195,28 @@ Content-Type: application/json
###字典获取
GET {{baseUrl}}/param/dict?first=SkinBase&second=imageResolution
\ No newline at end of file
GET {{baseUrl}}/param/dict?first=SkinBase&second=imageResolution
###国密4加密
POST {{baseUrl}}/api/encrypt
Content-Type: application/json
{
"algorithm": "SM4",
"content": "ererfeiisgod",
"key": "QZTiVtyFIUjMCVLs",
"password": "QZTiVtyFIUjMCVLs",
"url": "https://cdsmk.cdrsigc.com/engine/rest/99999800009"
}
###国密4解密
POST {{baseUrl}}/api/decrypt
Content-Type: application/json
{
"algorithm": "SM4",
"content": "tbP0GEuSqSboA8qHissswQ==",
"key": "QZTiVtyFIUjMCVLs",
"password": "QZTiVtyFIUjMCVLs"
}
\ No newline at end of file
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