如何找到文件的 MD5 哈希值? [英] How to find the MD5 hash of a file?

查看:186
本文介绍了如何找到文件的 MD5 哈希值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给定一个已知文件路径的文件,如何在 AHK 中为该文件生成 MD5 哈希值,而无需在代码中重新实现整个 MD5 哈希算法,例如 这个帖子有什么作用?

Given a file with a known file path, how can you generate an MD5 hash for the file in AHK, without reimplementing the entire MD5 hashing algorithm in the code, like this post does?

推荐答案

我们可以使用 Windows CertUtil 工具找到 MD5 哈希和并通过 StrSplit 将其分成不同的行(MD5 总和本身将在第二行).

We can use the Windows CertUtil tool to find the MD5 hash sum and Parse the output by StrSpliting it into different lines (The MD5 sum itself will be on the second line).

使用的cmd命令:

CertUtil -hashfile %appdata%/appsettings/app.ini MD5

(注意:将 %appdata%/appsettings/app.ini 替换为您的实际文件路径)

(Note: replace %appdata%/appsettings/app.ini with your actual file path)

最终代码:

var:= ComObjCreate("WScript.Shell").Exec("cmd.exe /q /c CertUtil -hashfile %appdata%/appsettings/app.ini MD5").StdOut.ReadAll()
MsgBox %var%
outputArr := (StrSplit(var , "`r`n"))
out:=outputArr[2]
MsgBox %out%

它已针对 Windows 10 进行了测试,尽管它也适用于某些旧版本.

It is tested for Windows 10, although it should work for some older versions as well.

这篇关于如何找到文件的 MD5 哈希值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆