标题:vb.net怎么计算文件的md5值
只看楼主
古123
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:14
帖 子:219
专家分:1098
注 册:2017-2-5
结帖率:86.67%
 问题点数:0 回复次数:2 
vb.net怎么计算文件的md5值
如题,谢谢各位大佬!
搜索更多相关主题的帖子: vb.net 计算 文件 md5 
2019-08-02 12:05
yanzhu6356
Rank: 2
等 级:论坛游民
帖 子:14
专家分:90
注 册:2017-3-30
得分:0 
''' <summary>
    ''' 获取本地文件的MD5值
    ''' </summary>
    ''' <param name="strSource">文件地址</param>
    ''' <returns>文件的MD5</returns>
    ''' <remarks></remarks>
    Public Shared Function getMD5(ByVal strSource As String) As String
        Dim result As String = ""
 
        Try        
            Dim fstream As New FileStream(strSource, FileMode.Open, FileAccess.Read)
            Dim dataToHash(fstream.Length - 1) As Byte
            fstream.Read(dataToHash, 0, fstream.Length)
            fstream.Close()
            Dim hashvalue As Byte() = CType(CryptoConfig.CreateFromName("MD5"), HashAlgorithm).ComputeHash(dataToHash)
            Dim i As Integer
            For i = 0 To hashvalue.Length - 1
                result += Microsoft.VisualBasic.Right("00" + Hex(hashvalue(i)).ToLower, 2)
            Next
            Return result
        Catch ex As Exception
            Return ex.Message
        End Try
 
    End Function
2019-08-12 11:25
古123
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:14
帖 子:219
专家分:1098
注 册:2017-2-5
得分:0 
回复 2楼 yanzhu6356
谢谢,抱歉,发帖时忘记了写积分,我重新发一个贴,你随便回复些,结贴时,我给你20积分,非常抱歉!
2019-08-18 20:25



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-496196-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.079712 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved