Feedback

VB - Den SHA1 Hash eines Strings ermitteln

Veröffentlicht von am 6/3/2006
(1 Bewertungen)
Den SHA1 Hash eines Strings ermitteln
Imports System.Security.Cryptography
Imports System.Text

Public Function SHA1StringHash(ByVal strString As String) As String
    Dim SHA1 As New SHA1CryptoServiceProvider
    Dim Data As Byte()
    Dim Result As Byte()
    Dim Res As String = ""
    Dim Tmp As String = ""

    Data = Encoding.ASCII.GetBytes(strString)
    Result = SHA1.ComputeHash(Data)
    For i As Integer = 0 To Result.Length - 1
        Tmp = Hex(Result(i))
        If Len(Tmp) = 1 Then Tmp = "0" & Tmp
        Res += Tmp
    Next
    Return Res
End Function
Abgelegt unter SHA1, Hash, String.

Kommentare zum Snippet

 

Logge dich ein, um hier zu kommentieren!