[VB.NET]MD5

来源:互联网 发布:广数g92螺纹编程实例 编辑:程序博客网 时间:2024/05/23 11:51
<script type="text/javascript"><!--google_ad_client = "pub-8333940862668978";/* 728x90, 创建于 08-11-30 */google_ad_slot = "4485230109";google_ad_width = 728;google_ad_height = 90;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>

  1. Function GetMd5Hash(ByVal input As String, ByVal coda As Integer) As String
  2.         Dim md5Hasher As New MD5CryptoServiceProvider()
  3.         Dim data As Byte() = md5Hasher.ComputeHash(Encoding.Default.GetBytes(input))
  4.         Dim sBuilder As New StringBuilder()
  5.         Dim i As Integer
  6.         If coda = 16 Then
  7.             For i = 4 To 11
  8.                 sBuilder.Append(data(i).ToString("x2"))
  9.             Next i
  10.         Else '32位
  11.             For i = 0 To 15
  12.                 sBuilder.Append(data(i).ToString("x2"))
  13.             Next i
  14.         End If
  15.         Return sBuilder.ToString()
  16. End Function

原创粉丝点击