encrypted data
Even with SSL
or https
available, there sometimes is a need to encrypt or encode the data that is sent over the line.
And there always will be the ultimate paranoid who doesn't trust anything.
Out of curiousity how it's done I searched the web for the answer :
Google ➠ encrypt+form+data+before+submit
The emphasis is on form input
, such as logins.
Three solutions from simple, complex and more complex are shown. Each with a sample page and demo set you can download.
You might call it ➠ End 2 End Encryption
Data captured with ➠ Wireshark
Each character is ➠ 'xor'
ed and then encoded to Base64
in JavaScript.
At the server the reverse is done in PHP.
The decoded text is then used to find the username and password in a database and displayed in a webpage.
The input
fields are encrypted with a random string to a JSON
formatted string.
At the server the reverse is done in PHP.
The decoded text is then used to find the username and password in a database and the result displayed in a webpage.
The result can also be encrypted into a JSON
string and sent back to the browser where it is decrypted in readable text.
This sample page doesn't use that feature, but the original code has a demo page.
The form input fields are POST
'ed and captured by the JavaScript. The POST
data is added to an array variable and then encrypted.
At the server the array is decrypted to a $_POST
array where PHP can process it.
The username and password are looked up in the database.
Unlike the previous example, the lookup data is added to an array variable with a $key->$value
pair, encrypted and sent to the browser.
The JavaScript decrypts the array and uses the $key->$value
pair to put the data into input
fields of a form.
This requires that a form
is used in the webpage, for example where the data can be edited by the user.
In other cases the lookup data can simply be sent back as in the previous examples.
Even though https
connections are used today, there will always be a situation where this is not the case. You know best.
And when you're obsessed with security, then here's the answer.
And why not do it for fun?
➠ JavaScript Deobfuscator and Unpacker
⇪ May 13 2022 19:42:38