Skip to content

Latest commit

 

History

History
11 lines (10 loc) · 612 Bytes

File metadata and controls

11 lines (10 loc) · 612 Bytes

PHP-form-RSA-encryption

Encrypt transmitted data with JavaScript with RSA keys, and decrypt on server side. Avoiding man-in-the-middle attack on HTTP network.

How it works?

  1. Server send server time to JS.
  2. JS calculate time difference since page load and form submit.
  3. Add this time difference to server time.
  4. Encrypt text field with UNIX time stamp to the end with public RSA key.
  5. Server decrypt string with private RSA key.
  6. PHP compare string time with actual server time.
  7. If time is less than 30 seconds, it is ok; If more than 30 seconds, something strange is happening.