Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use java security to sort out the RSA encryption and decryption process

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

Today, I will talk to you about how to use java security for RSA encryption and decryption process finishing, many people may not know much, in order to let everyone know more, Xiaobian summarized the following content for everyone, I hope you can harvest according to this article.

1. RSA encryption signature generation process [private key encryption] 1.1 preparation parameters encapsulated into Map

see code

getSignResult method 1.2 Remove elements in Map where value is empty and key is a signature parameter

see code

Method paraFilter(sParaTemp) in MagCoreUtil 1.3 Generate signature results 1.3.1 Sort parameter keys in ASCII order

see code

CreateLinkString method in MagCoreUtil 1.3.2 Connect parameters in Map into String according to "parameter = parameter value" mode and with "&" symbol

see code

CreateLinkString method in MagCoreUtil 1.3.3 Obtain signature result using above string, private key and encoding format

see code

RSA.sign(prestr, privateKey, inputCharset);1.4 Add signature result and signature method to Map

see code

buildRequestPara method in MagCoreUtil 2. RSA decryption verification signature process [public key decryption] 2.1 stream reading method to obtain "parameter = parameter value" and "&" connected parameters

see code

Signature verification code part getPostData method 2.1.1 Spring Boot stream reading parameter method

address

https://my.oschina.net/u/3193075/blog/30805522.2 encapsulates the acquired parameters into a Map

see code

signature verification part transferToMap method 2.3 verify digital signature 2.3.1 remove value is empty and key is sign (signature result) data to obtain a new Map

see code

ParaFilter2.3.2 in MagCoreUtil sorts the Key of the Map processed above according to ASCII code and encapsulates it into "parameter = parameter value" mode. Connect it with "&" to get StringMethod createLinkString2.3.3 in MagCoreUtil. Use RSA signature verification to check the parameters of String, signature mode, encoding format and public key.

see code

RSA.verify(src, sign, BdPayCommData.BD_PUBLIC_KEY, charset) method 2.4 Continue Other Business 3. description

Full Code Reference

https://gitee.com/YuHuaShan/codes/ewaqxptsri46u1lc53nm097 After reading the above content, do you have any further understanding of how to use java security for RSA encryption and decryption process sorting? If you still want to know more knowledge or related content, please pay attention to the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report