title: PHP Two Way Encryption With Checksum
body: <p>I am trying to pass a JSON string from one web application to another using URL parameters (for an internal SSO server). </p>
  
  <p>What I need to do is be able to encrypt the JSON string (which is a user payload object) with a pre-shared key, forward the user to the service provider application with the payload attached as a URL parameter and then on the service provider application decrypt the payload back into a JSON string to get the required information.</p>
  
  <p>Now this part isn't as much of an issue thanks to all of PHP's built in encryption functions but the next part is the difficulty. I am needing to embed a checksum within the encrypted string which can be checked when decrypting it so that if it has been modified in transit then I can raise an exception.</p>
  
  <p>The purpose of this is to make sure that the user payload has not been modified in transit either accidentally or deliberately.</p>