I have created a form which will take input from user in the form of password. Then I want to encode it at client side and then decrypt it on server side. So wanted to encode using JS and decode using PHP. So wrote JS code mentioned below:
<script>
function doThis()
{
document.myform.password.value = "hello" + document.myform.password.value; // Considering this as encoded data
return true;
}
</script>
When I try to encode this data it causes issue, which is because I am not using right encoding algorithm. After a bit of search I found one encode decode methods base64_decode and base64_encode, both are of PHP. So I want to know if there is any way I can encode in JS and decode in PHP so that i can get correct data. On server I am using below code:
$password = base64_decode($_POST['password']);
HTML code:
<form name="myform" onsubmit="return doThis()" action="admin.php" method="post">
<input type="password" name="password" id='password'>
<input type="submit" value="SignIn">
This will help in protecting password while sending from client to server. I don't want to use SSL, but still want to protect password from fishing or other kind of attacks.
Please help understand this with example of code. If i can use any other encryption algorithm, please help me understand using code. Also can achieve this only through PHP?, i googled and found that we need JS for doing it, as need to encode at client side, but as using PHP so want to decode it using PHP.