Php interface data encryption, decryption, verification signature code instance

Source: Internet
Author: User
Tags crypt
Php interface data encryption, decryption, signature verification code instance php interface data encryption, decryption, signature verification code is very simple, there is not much nonsense here, directly provide the code & lt ;? Php **** data encryption, decryption, authentication signature * @ editwww.lai18.com * @ date2015-07-08 ** header (Content-Type: textxml; charset php interface data encryption, decryption, signature verification code instance
Php interface data encryption, decryption, signature verification

The code is very simple, so there is not much nonsense here, and the code is provided directly.

 SetKey ($ aeskey); // decrypt AES ciphertext $ plaintext = $ aes-> decrypt (base64_decode ($ crypttext); echo $ plaintext; echo'
 '; // AES encrypted plaintext // echo $ aes-> encrypt ($ plaintext ); // rsa public key $ publickey = 'signature + rDknXLqMT + signature/Signature/A0Vfb0 + xM8MnF46DdhhrnZrycERBSbyrcwIDAQAB '; // echo base64_decode ($ publickey ); // rsa signature $ signature = 'xhin4uufqrkdehkbd/hQisXLFFSxM6EZCvCPqnWCQJq3uEp3ayxmFuUgVE0Xoh4A IWjIIsOWdnaToL1bXvAFKwjCtXnkaRwUpvWrk + signature + aumEAcPyYDxLhDN646Krzw = '; // echo base64_decode ($ signature); $ rsa = new Crypt_RSA (); // Set the RSA signature mode CRYPT_RSA_SIGNATURE_PSS or CRYPT_RSA_SIGNATURE_PKCS1 $ rsa-> setSignatureMode (signature); // var_dump ($ rsa-> createKey ()); // Generate the RSA public key and private key // extract ($ rsa-> createKey ()); // use the RSA private key to generate a signature // $ rsa-> loadKey ($ privatekey); // $ sign Ature = $ rsa-> sign ($ plaintext); // use the RSA public key to verify the signature echo $ plaintext; $ rsa-> loadKey (base64_decode ($ publickey )); echo $ rsa-> verify ($ plaintext, base64_decode ($ signature ))? 'Verified ': 'unverified'; echo'
 '; // Generate the RSA public key, private key // var_dump ($ rsa-> createKey (); extract ($ rsa-> createKey ()); // use the RSA private key to encrypt data $ rsa-> loadKey ($ privatekey); $ ciphertext = $ rsa-> encrypt ($ plaintext ); // use the RSA public key to decrypt data $ rsa-> loadKey ($ publickey); echo $ rsa-> decrypt ($ ciphertext );

Every time you talk about any transactions involving money and transactions, you need to pay special attention to security issues, such as developing a forum or a shopping cart.

Additional reading

Collect a series of technical articles on "PHP practical problem solving cases"

1 PHP Chinese character Pinyin Conversion and Gregorian calendar conversion

2php shopping cart implementation

How to display the size of formatted file data in 3PHP

How to display the number of online users of a website in 4PHP + jquery in real time

5PHP is used to determine whether a user accesses a mobile phone

Function for escaping special characters in Json in 6PHP

7 PHP implements SMTP mail sending method based on socket

How to query express information in 8PHP

9PHP simple video preview method

10php interface data encryption, decryption, signature verification

11php calculates the space occupied by files in a specified directory

12php recursively copies directories and subdirectories

How to delete the entire directory through DirectoryIterator in 13php

14PHP generates download link code instances for software such as thunder, express train, and tornado.

15PHP Chinese garbled classification and solutions

16php randomly selects several non-repeating elements from the array

Summary of 17PHP file upload problems-file size detection and large file Upload processing

18 how to modify the memory_limit limit of PHP

19php method for determining whether a request is an ajax request or a common request

20 PHP super powerful Infinitus classification spanning tree method

21 analysis on the principles of long weibo generation (converting html into images)

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

1st floor qq2291738886 yesterday
2291738886

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.