Rsa public key has garbled characters after decryption (garbled characters + plaintext)

After decryption, there are garbled characters, as shown in the figure below (garbled characters + plaintext).
insert image description here
The reason is the encrypted padding method:

 Cipher cipher = Cipher.getInstance("RSA");//错误,会导致乱码

The correct one should be

 Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");

ok, it is displayed normally after modification
insert image description here

Guess you like

Origin blog.csdn.net/mingtiannihao0522/article/details/117474208