标签:AC stat ati false function str elf .com UI
<?php class Crumb { const SALT = ‘http:test.com‘; static $ttl = 7200; static public function issueCrumb($uid, $ttl=7200, $action= -1) { if(intval($ttl)>7200) self::$ttl = $ttl; $i = ceil(time() / self::$ttl); return substr(self::challenge($i . $action . $uid), -12, 10); } static public function challenge($data) { return hash_hmac(‘md5‘,$data, self::SALT); } static public function verifyCrumb($uid,$crumb, $action= -1) { $i = ceil(time() / self::$ttl); if(substr(self::challenge($i . $action . $uid), -12, 10) == $crumb || substr(self::challenge(($i-1) . $action . $uid), -12, 10) == $crumb){ return true; }else{ return false; } } } $crumb = Crumb::issueCrumb(1); //var_dump($crumb); //die; $crumb = ‘fc3c0f7c23‘; $ver = Crumb::verifyCrumb(1,$crumb); var_dump($ver);
标签:AC stat ati false function str elf .com UI
原文地址:https://www.cnblogs.com/lujiang/p/9001802.html