title: Encrypt data using JS and decrypt PHP in a form
body: <p>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:</p>
  
  <pre><code>&lt;script&gt;
      function doThis()
      {
          document.myform.password.value = "hello" + document.myform.password.value; // Considering this as encoded data
          return true;
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>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:</p>
  
  <pre><code>$password = base64_decode($_POST['password']);
  </code></pre>
  
  <p>HTML code:</p>
  
  <pre><code>&lt;form name="myform" onsubmit="return doThis()" action="admin.php" method="post"&gt;
  &lt;input type="password" name="password" id='password'&gt;
  &lt;input type="submit" value="SignIn"&gt;
  </code></pre>
  
  <p>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.</p>
  
  <p>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.</p>