已解决 hmac函数未定义


禅道版本 11.6.stable 源码包
操作系统 CentOS
客户端浏览器 Chrome

提问者: MES 悬赏:5 日期: 2019-08-22 11:43:32 答案:1 点击:1002

获取技术支持

QQ: 电话:
设置备注
答案列表
最佳答案
2019/08/22

提示的这个文件,打开,然后追加下下面代码,看下呢?

/**
 * Calculate an MD5 HMAC hash.
 * Works like hash_hmac('md5', $data, $key)
 * in case that function is not available.
 *
 * @param string $data The data to hash
 * @param string $key  The key to hash with
 *
 * @return string
 */
protected function hmac($data, $key)
{
    if (function_exists('hash_hmac')) {
        return hash_hmac('md5', $data, $key);
    }
    // The following borrowed from
    // http://php.net/manual/en/function.mhash.php#27225
    // RFC 2104 HMAC implementation for php.
    // Creates an md5 HMAC.
    // Eliminates the need to install mhash to compute a HMAC
    // by Lance Rushing
    $bytelen = 64; // byte length for md5
    if (strlen($key) > $bytelen) {
        $key = pack('H*', md5($key));
    }
    $key = str_pad($key, $bytelen, chr(0x00));
    $ipad = str_pad('', $bytelen, chr(0x36));
    $opad = str_pad('', $bytelen, chr(0x5c));
    $k_ipad = $key ^ $ipad;
    $k_opad = $key ^ $opad;
    return md5($k_opad . pack('H*', md5($k_ipad . $data)));
}


2019/08/22
使用该函数,问题解决。