哈希加密的簡單類

Imports System.Security.Cryptography
Public Class Class1


    Function Hashjm(ByVal TextToHash As String)
        Dim SHA1 As SHA1CryptoServiceProvider
        Dim bytValue() As Byte
        Dim bytHash() As Byte
        SHA1 = New SHA1CryptoServiceProvider
        bytValue = System.Text.Encoding.UTF8.GetBytes(TextToHash)
        bytHash = SHA1.ComputeHash(bytValue)
        SHA1.Clear()
        Return Convert.ToBase64String(bytHash)
    End Function


    Function Md5jm(ByVal TextToHash As String)
        Dim md5 As MD5CryptoServiceProvider
        Dim bytValue() As Byte
        Dim bytHash() As Byte
        md5 = New MD5CryptoServiceProvider
        bytValue = System.Text.Encoding.UTF8.GetBytes(TextToHash)
        bytHash = md5.ComputeHash(bytValue)
        md5.Clear()
        Return Convert.ToBase64String(bytHash)
    End Function
End Class

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章