Public key usage of php rsa encryption, decryption, signature and verification
This article introduces the knowledge about "php rsa encryption, decryption, signature, and public key usage of signature verification". In the actual case operation process, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!
php rsa encryption, decryption, signature, signature verification
Since the docking third-party organization uses the Java version of the rsa encryption and decryption method, all the PHP versions of rsa encryption and decryption have just been found on the Internet, but most of the docking java is not applicable.
The following php version is suitable for docking java interface, java is suitable for key and php language use is required to add
-----BEGIN CERTIFICATE----- -----END CERTIFICATE-----
Use key:
encryption public key public_key.cer
decryption private key private_key.key
sign_key.key
public key verified.cer
Note:
Sometimes after encryption with base64_encode, in the form of GET to other pages, decryption with base64_decode, garbled.
When I encounter this problem, I wonder why some of them can be decrypted correctly, but some of them appear garbled?
Later, after checking, we found that there are some Chinese characters. When they are passed in GET form, the + sign will be replaced by a space.
In order to prevent the occurrence of garbled, I did a step replacement, and then decrypted, sure enough, garbled problem, no longer exists!
For example, if you pass an oid variable in the form of GET, then when decrypting and restoring, replace the space with a + sign. Then the output is normal.
$oid=base64_decode(str_replace(" ","+",$_GET[oid]));
"php rsa encryption, decryption, signature, verification of the public key usage" content is introduced here, thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!