php 和 c# 中的 hmac_sha256 不同
这是我的 PHP 代码:
hash_hmac( "sha256", utf8_encode( $filename ), utf8_encode( $password ) );
这是我的 C# 代码:
var hmacsha256 = new HMACSHA256( Encoding.UTF8.GetBytes( password ) );
hmacsha256.ComputeHash( Encoding.UTF8.GetBytes( filename ) );
不幸的是,两个结果不同。 谁能给我提示吗?
this is my PHP code:
hash_hmac( "sha256", utf8_encode( $filename ), utf8_encode( $password ) );
and this is my C# code:
var hmacsha256 = new HMACSHA256( Encoding.UTF8.GetBytes( password ) );
hmacsha256.ComputeHash( Encoding.UTF8.GetBytes( filename ) );
unfortunately both results differ. Can anyone give me a hint?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的 C# 不是最好的,但我让它可以工作,你需要做的是将字节数组结果转换为十六进制。
PHP
C#
My C# is not the best but i got it to work, what you need to do is to convert your byte array results to hex.
PHP
C#