How to hash a string correctly

Will the following function correctly hash my provided string? Or am I missing something fundamentally important?

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
+3
source share
2 answers

Looks nice. Satisfying the salt is important, although it remains challenging that the salt is unique.

+2
source

I think you have the best practice there, namely hash salting. This is very important and often overlooked. It looks good to me.

+2
source

Source: https://habr.com/ru/post/1752878/


All Articles