Jump to content
php.lv forumi

Šifrētu datu izvadīšana no datubāzes


djmartins

Recommended Posts

Man ir radusies neliela problēma. Šifrētus datus izdodās ievietot mysql datubāzē, taču neizdodās izvadīt no datubāzes atšifrētu rezultātu. Tiek izvadīti ķeburi. Īsti neizprotu, kur varētu būt problēma.

 


<?php
$res=mysql_query("select * from lietotaji where niks='$user'") or die(mysql_error());
$rez=mysql_fetch_array($res); {
$vards=htmlentities($rez['vards'],ENT_QUOTES, "UTF-8");
}
$key="XiTo74dOO09N48YeUmuvbL0E";
$iv = mcrypt_create_iv (mcrypt_get_block_size(MCRYPT_CAST_256, MCRYPT_MODE_CBC), MCRYPT_DEV_RANDOM);
function decrypt($string,$key) {
$dec = "";
$string = trim(base64_decode($string));
global $iv;
$dec = mcrypt_cbc (MCRYPT_CAST_256, $key, $string, MCRYPT_DECRYPT, $iv);
return $dec;
}

$vards2 = decrypt($vards, $key);


?>

[/Code]

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...