Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
device-new-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
赵啸非
device-new-platform
Commits
bd785a93
Commit
bd785a93
authored
May 11, 2022
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改消息组件
parent
e102dfe0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
0 deletions
+44
-0
device-manager/src/main/java/com/mortals/xhx/common/security/TestDemo.java
...c/main/java/com/mortals/xhx/common/security/TestDemo.java
+44
-0
No files found.
device-manager/src/main/java/com/mortals/xhx/common/security/TestDemo.java
0 → 100644
View file @
bd785a93
package
com.mortals.xhx.common.security
;
import
com.mortals.framework.util.security.sm.SM2Utils
;
import
com.mortals.framework.util.security.sm.SM4Utils
;
import
com.mortals.framework.util.security.sm.SMCipher
;
import
com.mortals.framework.util.security.sm.Util
;
import
org.apache.commons.codec.binary.Base64
;
import
static
com
.
mortals
.
framework
.
util
.
security
.
sm
.
SM2Utils
.
encrypt
;
/**
* 服务调用示例
*
*/
public
class
TestDemo
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
String
plainText
=
"{\"fwid\":\"511010020304102\",\"machine\":{\"mac\":\"10-63-C8-30-B1-F9\",\"ip\":\"192.168.78.158\",\"zdbm\":\"DCKJ0100201706010653000000000000\"},\"data\":{\"qrcode\":\"5101000001177421384867\"}}"
;
SM4Utils
sm4
=
new
SM4Utils
();
sm4
.
setSecretKey
(
"1234567890123456"
);
System
.
out
.
println
(
"明文: "
+
plainText
);
String
transformation
=
"SM4/ECB/Padding"
;
SMCipher
clipher
=
SMCipher
.
getInstance
(
transformation
);
clipher
.
init
(
1
,
sm4
.
getSecretKey
().
getBytes
(),
sm4
.
getIv
().
getBytes
());
byte
[]
result
=
clipher
.
doFinal
(
plainText
.
getBytes
());
System
.
out
.
println
(
Base64
.
encodeBase64URLSafeString
(
result
));
/* SM2Utils sm2Utils = new SM2Utils();
SM2Utils.generateKeyPair();
String plainText = "ererfeiisgod";
byte[] sourceData = plainText.getBytes();
//私钥
String prik = "3690655E33D5EA3D9A4AE1A1ADD766FDEA045CDEAA43A9206FB8C430CEFE0D94";
//公钥
String pubk = "04F6E0C3345AE42B51E06BF50B98834988D54EBC7460FE135A48171BC0629EAE205EEDE253A530608178A98F1E19BB737302813BA39ED3FA3C51639D7A20C7391A";
System.out.println("\u52a0\u5bc6: ");
String cipherText = encrypt(Util.hexToByte(pubk), sourceData);
System.out.println(cipherText);*/
}
}
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