Code: Select all
<?php
function decode($string,$key) {
$key = sha1($key);
$strLen = strlen($string);
$keyLen = strlen($key);
for ($i = 0; $i < $strLen; $i+=2) {
$ordStr = hexdec(base_convert(strrev(substr($string,$i,2)),36,16));
if ($j == $keyLen) { $j = 0; }
$ordKey = ord(substr($key,$j,1));
$j++;
$hash .= chr($ordStr - $ordKey);
}
return $hash;
}
$teste2 = decode("j4v59454i484t5r4r4","this is a key" );
echo "$teste2";
?>
i tried like this
Code: Select all
// $teste2 = decode("j4v59454i484t5r4r4","this is a key" );
$sql = mysql_query("SELECT * FROM data WHERE id='1'", $conexao);
$Rsql = mysql_fetch_array($sql);
$string1= $Rsql[chave1];
$string2= $Rsql[chave2];
$teste2 = decode($string1,$string2); //not works
$teste2 = decode($Rsql[chave1],$Rsql[chave2]); //not works
echo "$teste2";