.net 如何正确地散列字符串

.net 如何正确地散列字符串,.net,hash,.net,Hash,下面的函数能否正确地散列我提供的字符串?还是我错过了一些根本重要的东西 Private Function HashString(ByVal value As String, ByVal salt As String) As String Dim dataBytes As Byte() = System.Text.Encoding.UTF8.GetBytes(value + salt) Dim hash As New System.Security.Cryptography.SH

下面的函数能否正确地散列我提供的字符串?还是我错过了一些根本重要的东西

Private Function HashString(ByVal value As String, ByVal salt As String) As String

    Dim dataBytes As Byte() = System.Text.Encoding.UTF8.GetBytes(value + salt)
    Dim hash As New System.Security.Cryptography.SHA512Managed
    Dim hashBytes As Byte() = hash.ComputeHash(dataBytes)

    Return Convert.ToBase64String(hashBytes)

End Function

我觉得不错。允许添加盐是很重要的,尽管这仍然要由调用者来确保盐是唯一的。

我认为你有最好的做法,即腌制土豆条。这一点非常重要,常常被忽视。看起来不错。

似乎有点容易成为事实,尤其是有这么多更复杂的例子。非常感谢。