title: How to encrypt and decrypt data in php?
body: <p>How to encrypt and decrypt data in php?</p>
  
  <p>My code so far is:-</p>
  
  <pre><code>function encrypter($plaintext)
  {
      $plaintext = strtolower($plaintext);
      $crypttext = mcrypt_encrypt(MCRYPT_RIJNDAEL_256,FLENCKEY,$plaintext,MCRYPT_MODE_ECB);    
      return trim(base64_encode($crypttext));
  }
  
  function decrypter($crypttext)
  {
      $crypttext = base64_decode($crypttext);    
      $plaintext = mcrypt_decrypt(MCRYPT_RIJNDAEL_256,FLENCKEY,$crypttext,MCRYPT_MODE_ECB);    
      return trim($crypttext);
  }
  </code></pre>
  
  <p>$test = "abc@gmail.com";</p>
  
  <p>echo encrypter(test);</p>
  
  <p><strong>Output is</strong> </p>
  
  <pre><code>iLmUJHKPjPmA9vY0jfQ51qGpLPWC/5bTYWFDOj7Hr08=
  </code></pre>
  
  <p>echo decrypter(test);</p>
  
  <p><strong>Output is</strong> </p>
  
  <pre><code>��-
  </code></pre>