将算法/代码从Ruby转换为PHP

时间:2009-12-07 22:30:13

标签: php ruby encryption hash sha1

digest = HMAC.digest(Digest.new(SHA1), Base64.decode64(key), HashString) return Base64.encode64(digest.to_s()).chomp()

上述内容在PHP中会是什么?

1 个答案:

答案 0 :(得分:2)

这应该这样做:

$digest = hash_hmac("sha1", $hash_string, base64_decode($key), true);
return base64_encode($digest);