用目录作为字符串计算MD5哈希值?

编程入门 行业动态 更新时间:2024-10-28 04:23:26
本文介绍了用目录作为字符串计算MD5哈希值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

您好我有点问题。我正在尝试为给定文件执行MD5哈希算法,但我所拥有的只是作为字符串的目录。 例如我将此作为我的字符串.. C:\ Users \Subfolder\file.exe 如何使用字符串找到文件然后再计算文件的md5哈希值而不仅仅是字符串的md5计算? 提前谢谢!

Hello I have somewhat of a problem. I am trying to execute a MD5 hashing algorithm for a given file but all I have is the directory as a string. for example I have this as my string.. C:\Users\Subfolder\file.exe How can I use the string to locate the file to then calculate the md5 hash of the file and not just the md5 calculation of the string? thank you in advance!

推荐答案

Imports System.Security.Cryptography Imports System.Text Imports System.IO Public Function MD5FileHash(ByVal sFile As String) As String Dim MD5 As New MD5CryptoServiceProvider Dim Hash As Byte() Dim Result As String = "" Dim Tmp As String = "" Dim FN As New FileStream(sFile, FileMode.Open, FileAccess.Read, FileShare.Read, 8192) MD5.ComputeHash(FN) FN.Close() Hash = MD5.Hash Result = Strings.Replace(BitConverter.ToString(Hash), "-", "" Return Result End Function

应该这样做^^

should do the trick ^^

更多推荐

用目录作为字符串计算MD5哈希值?

本文发布于:2023-10-22 22:46:40,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1518951.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符串   目录   哈希值

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!