基本上和MD5差不多
SHA1 算法的哈希值大小为 160 位。
SHA256 算法的哈希值大小为 256 位。
SHA512 算法的哈希值大小为 512 位。
SHA1目前还没什么问题,如果大家还不放心可以用SHA256和SHA512,当然强度越高的算法运行时间就要更长一些,不过以目前的配置来说,平常的应用几乎是感觉不出来的。
函数
    Function mySHA(ByVal SourceStr As String) As String 'SHA1加密算法
        Dim SHA As New System.Security.Cryptography.SHA1CryptoServiceProvider 'sha1加密
        'Dim sha As New System.Security.Cryptography.SHA256Managed'sha256加密
        'Dim sha As New System.Security.Cryptography.SHA512Managed 'sha512加密
        Dim bytValue() As Byte '输入
        Dim bytHash() As Byte '输出
        bytValue = System.Text.Encoding.UTF8.GetBytes(SourceStr) '输入字符转为byte
        bytHash = SHA.ComputeHash(bytValue) '加密
        SHA.Clear()
        mySHA = Convert.ToBase64String(bytHash) '转为字符
    End Function
 
引用
        Dim mytxt, msgtxt As String
        mytxt = "nyfort的BLOG"
        msgtxt = "nyfort的BLOG" & vbCrLf & "的SHA是" & vbCrLf & mySHA(mytxt)
        MessageBox.Show(msgtxt, "SHA")

我们不Hack软件,我们只是优秀软件的搬运工。
麦氪搜(iMacSO.com) » VB.NET的SHA1加密