doumen5895 2015-11-16 06:36
浏览 161

验证sha256哈希

I am trying to verify that this hash was not messed with, and use the time stamp to do so. I know there is no way to reverse a hash without brute force. How would I be able to verify it at a later date?

Is there a php code I dont know about?

Please and thank you.

$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条回答 默认 最新

  • douzhuo5671 2015-11-16 06:45
    关注

    Generate the string you think php is hashing and pass it to a different sha256 calculator to compare the results. There are online calculators - just google sha256 online to get one. Alternatively, on linux/OSX there is a terminal sha256 calculator (sha256sum on my linux). It could be used in the terminal as follows:

    echo "string to sha" | sha256sum
    

    Hope this helps.

    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?