php - securely send data from one site to another? -


I am going to post some data from one website to another. I have a way to get the website, to ensure that the data was sent from the sending website and some other malicious user was not sent. I am using PHP4.

How can I do this?

Thank you!

To resolve only one PHP:

< P> If you can keep a secret (at both ends), then the self-implemented version (yes, one version)

The concept is that if you have only one secret on both ends, So you can get the hash (message + secret) on the end of sending, and (message + secret) end. If there is a hash match, then you have a valid message.

It is a secret key because without a secret, it is impossible that an attacker can change the message and generate a new hash that will verify on the receiving end.

Here are some examples of PHP code:

  // at the end of sending: define ('SECRET', '12734981273912379128739128739127938794729327492'); $ Message = 'your message'; $ Packet = $ message sha1 (message $ SECRET); // Receive Finally: Define ('SECRET', '12734981273912379128739128739127938794729327492'); $ Message = substr ($ packet, 0, -40); If (sha1 (message $ SECRET)! = Substr ($ packet, -40)) Throw new exceptions ("message authentication failed!") And do_something_with ($ message);  

If you want additional security to post the same message from a hacker, then you can add a random request identifier for each request, and make sure that the same hash Has never been accepted.

>

Disclaimer: Before being trusted with sensitive data, peer review and verification should be done with all security sensitive code. Through research on the topic or better yet, use an existing library which handles this kind of verification + certification.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -