现在的位置: 首页 > 综合 > 正文

哈希加密的简单类

2013年06月10日 ⁄ 综合 ⁄ 共 761字 ⁄ 字号 评论关闭

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

抱歉!评论已关闭.