哈希加密的简单类

来源:互联网 发布:没有凶手的杀人夜 知乎 编辑:程序博客网 时间:2024/06/15 05:24

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

原创粉丝点击