【发布时间】:2014-09-23 19:27:30
【问题描述】:
我正在将一些代码从 .net (vb) 移植到 php,我遇到了一些我无法在 php 中重现的 md5 散列。在 .net 中,有两个函数,一个使用 UTF-8 编码,另一个使用 Unicode 编码。在字符串中传递时输出是不同的哈希
// First function (returns GUID)
Dim oHasher As Cryptography.MD5 = Cryptography.MD5.Create()
Dim oEncoder As New System.Text.UTF8Encoding()
Dim csData() As Byte
csData = oHasher.ComputeHash(oEncoder.GetBytes(strInput))
// Second function (returns GUID)
Dim oHasher As Cryptography.MD5 = Cryptography.MD5.Create()
Dim oEncoder As New System.Text.UnicodeEncoding()
Dim csData() As Byte
csData = oHasher.ComputeHash(oEncoder.GetBytes(strInput))
在php中我尝试过使用
$passHash = md5(utf8_encode($password));
$newPassHash = md5($password);
但它们都产生相同的结果。是否可以在 php 中使用 md5 散列产生相同的结果?
【问题讨论】: