Mysql garip sembolleri tanımak sahip iken, bir sunucu tarafı AES şifreleme ile mysql içine eklemek nasıl?

0 Cevap php


this is my first post and I'm very new with mysql and php.
I'm currently doing AES encryption for passwords. I'm using this encryption: http://www.phpclasses.org/package/4238-PHP-Encrypt-and-decrypt-data-with-AES-in-pure-PHP.html since we don't have SSL security and must protect our server side as well.

Bana bu gibi şifreli bir dize verir: '

Can you help this poor damsel? Thank you for your time.

 <?php
    $input = '123456';

function Encrypt($toEncrypt)
 {
   $Cipher = new AESCipher(AES::AES256);
   $password = 'superKeyHere'; 
   $cryptext = $Cipher->encrypt($toEncrypt, $password);
   return CleanUpString($cryptext);
 }

function Decrypt($toDecrypt)
{ 
  $Cipher = new AESCipher(AES::AES256); 
   $password = 'superKeyHere';
   $output = $Cipher->decrypt($toDecrypt, $password);
   return CleanUpString($output);
 }

 function CleanUpString($inp)
 {
    return str_replace(array("�", "ۓ"), array("=^_^=", "=^.^="), $inp); 
 } 

  $cryptext=Encrypt($input) ;
  //Encrypted
  print 'cryptext: '.$cryptext.'<br />';

   $oSql = new sql(0);
   $cryptext=mysql_real_escape_string($cryptext);
   $oSql->query("update userTab set pass='$cryptext' where id=1");

   $oSql = new sql(0);
   $oSql->query("select pass from userTab where id=1");
   $rows = $oSql->get_table_hash();
     $cryptext="";
    if (sizeof($rows) >0){
    $cryptext= $rows[0]["pass"];
    }
 $cryptext=Decrypt($cryptext);
 //Decrypted
 print 'message: '.$cryptext.'<br />'; 

 ?> 

0 Cevap