I have a table full of registrations and more are inserted daily. I need to hash the current passwords and the new coming in.
I'd like to use the SQL hashbytes function to hash the current records but don't know how to hash the new records thru vb.net
I've seen a few methods in vb.net but none that return the same result.
SQL
vb.net
I'd like to use the SQL hashbytes function to hash the current records but don't know how to hash the new records thru vb.net
I've seen a few methods in vb.net but none that return the same result.
SQL
Code:
set @password= hashbytes ('SHA1',@password)
vb.net
Code:
unction getSHA1Hash(ByVal strToHash As String) As String
Dim sha1Obj As New Security.Cryptography.SHA1CryptoServiceProvider
Dim bytesToHash() As Byte = System.Text.Encoding.ASCII.GetBytes(strToHash)
bytesToHash = sha1Obj.ComputeHash(bytesToHash)
Dim strResult As String = ""
For Each b As Byte In bytesToHash
strResult += b.ToString("x2")
Next
Return strResult
End Function
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Label1.Text = TextBox1.Text
Label2.Text = getSHA1Hash(TextBox1.ToString)
End Sub