如何正确地散列字符串
问题描述:
以下函数能否正确散列我提供的字符串?或者我错过了一些根本重要的东西?如何正确地散列字符串
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
答
看起来不错。允许食盐很重要 - 尽管它仍然留给调用者以确保盐是独一无二的。
答
我认为你有最好的做法,即哈希的腌制。这非常重要并且经常被忽视。在我看来很好。
看起来有点容易成为现实,特别是有这么多更复杂的例子浮出水面。谢谢。 – 2010-07-03 17:50:42