验证sha256哈希

时间:2015-11-16 06:36:35

标签: php hash encode sha256

我正在尝试验证此哈希没有搞乱,并使用时间戳来执行此操作。我知道没有蛮力就没有办法扭转哈希。我怎样才能在以后验证它?

是否有我不知道的PHP代码?

请,谢谢你。

$log = fopen($datalog, 'a') or die("can't open file");

echo " ";
echo "IP: ";
echo $address;
$addressHash = hash_hmac('sha256', $address,  $key);
$add64 = base64_encode($addressHash);
fwrite ($log, $add64);
echo " ";
echo "INFO: ";
echo $info;
$infoHash = hash_hmac('sha256', $info,  $key);
$info64 = base64_encode($infoHash);
fwrite ($log, $info64);
echo " ";
echo "TIMESTAMP: ";
echo $datetimeStamp;
$tsHash = hash_hmac('sha256', $datetimeStamp,  $key);
$ts64 = base64_encode($tsHash);
fwrite ($log, $ts64);
echo " ";
echo "COUNTRY: ";
echo $country;
$countryHash = hash_hmac('sha256', $country,  $key);
$country64 = base64_encode($countryHash);
fwrite ($log, $country64);
echo " ";
echo "LATITUDE: ";
echo $lat;
$latHash = hash_hmac('sha256', $lat,  $key);
$lat64 = base64_encode($latHash);
fwrite ($log, $lat64);
echo " ";
echo "LONGITUDE: ";
echo $long;
$longHash = hash_hmac('sha256', $long,  $key);
$long64 = base64_encode($longHash);
fwrite ($log, $long64);

fclose($log);

}

1 个答案:

答案 0 :(得分:0)

生成您认为php正在散列的字符串,并将其传递给另一个sha256计算器以比较结果。 有在线计算器 - 只需google sha256 online即可获得一个。或者,在linux / OSX上有一个终端sha256计算器(我的linux上有sha256sum)。它可以在终端中使用如下:

echo "string to sha" | sha256sum

希望这有帮助。