以下是C#和PHP的代码,我需要一些帮助。我正在尝试生成C#中的身份验证密钥,但希望在PHP中进行转换。一切都完成了,但我不知道如何在PHP中实现[System.Text],因为PHP中有hash_hmac(),但在同一函数中可能$string。
C# 版本
var hmac = new System.Security.Cryptography.HMACSHA256();
var buffer = userName + accessKey + timeStamp + originUrl;
var hash = hmac.ComputeHash(System.Text.Encoding.UTF8.GetBytes(buffer));
var authenticationKey = Convert.ToBase64String(hash);
版本
$hmac = hash_hmac('sha256', $string, $buffer);
$encoded = base64_encode($hmac);
任何人都可以帮我。这将是非常有帮助的。谢谢。
慕桂英546537
aluckdog
红颜莎娜