www.autohotkey.com
Open in
urlscan Pro
2606:4700:3032::ac43:dbcf
Public Scan
Submitted URL: https://autohotkey.com/board/topic/66139-ahk-l-calculating-md5sha-checksum-from-file/
Effective URL: https://www.autohotkey.com/board/topic/66139-ahk-l-calculating-md5sha-checksum-from-file/
Submission Tags: falconsandbox
Submission: On January 17 via api from US — Scanned from DE
Effective URL: https://www.autohotkey.com/board/topic/66139-ahk-l-calculating-md5sha-checksum-from-file/
Submission Tags: falconsandbox
Submission: On January 17 via api from US — Scanned from DE
Form analysis
3 forms found in the DOMPOST //www.autohotkey.com/board/index.php?app=core&module=search&do=search&fromMainBar=1
<form action="//www.autohotkey.com/board/index.php?app=core&module=search&do=search&fromMainBar=1" method="post" id="search-box">
<fieldset>
<label for="main_search" class="hide">Search</label>
<a href="//www.autohotkey.com/board/index.php?app=core&module=search&search_in=forums" title="Advanced Search" accesskey="4" rel="search" id="adv_search" class="right">Advanced</a>
<span id="search_wrap" class="right">
<input type="text" id="main_search" name="search_term" class="" size="17" tabindex="100" placeholder="placeholder">
<span class="choice ipbmenu clickable" id="search_options" style="">This topic</span>
<ul id="search_options_menucontent" class="ipbmenu_content ipsPad" style="display: none; position: absolute; z-index: 9999;">
<li class="title" style="z-index: 10000;"><strong style="z-index: 10000;">Search section:</strong></li>
<li class="special" style="z-index: 10000;">
<label for="s_topic" title="This topic" style="z-index: 10000;">
<input type="radio" name="search_app" value="forums:topic:66139" class="input_radio" id="s_topic" checked="checked" style="z-index: 10000;"><strong style="z-index: 10000;">This topic</strong>
</label>
</li>
<li class="app" style="z-index: 10000;"><label for="s_forums" title="Forums" style="z-index: 10000;"><input type="radio" name="search_app" class="input_radio" id="s_forums" value="forums" style="z-index: 10000;">Forums</label></li>
<li class="app" style="z-index: 10000;"><label for="s_members" title="Members" style="z-index: 10000;"><input type="radio" name="search_app" class="input_radio" id="s_members" value="members" style="z-index: 10000;">Members</label></li>
<li class="app" style="z-index: 10000;"><label for="s_core" title="Help Files" style="z-index: 10000;"><input type="radio" name="search_app" class="input_radio" id="s_core" value="core" style="z-index: 10000;">Help Files</label></li>
</ul>
<input type="submit" class="submit_input clickable" value="">
</span>
</fieldset>
</form>
POST //www.autohotkey.com/board/index.php?
<form id="modform" method="post" action="//www.autohotkey.com/board/index.php?">
<input type="hidden" name="app" value="forums">
<input type="hidden" name="module" value="moderate">
<input type="hidden" name="section" value="moderate">
<input type="hidden" name="do" value="postchoice">
<input type="hidden" name="f" value="49">
<input type="hidden" name="t" value="66139">
<input type="hidden" name="auth_key" value="880ea6a14ea49e853634fbdc5015a024">
<input type="hidden" name="st" value="">
<input type="hidden" name="page" value="">
<input type="hidden" value="" name="selectedpidsJS" id="selectedpidsJS">
<input type="hidden" name="tact" id="tact" value="">
</form>
POST //www.autohotkey.com/board/index.php?app=core&module=global§ion=login&do=process
<form action="//www.autohotkey.com/board/index.php?app=core&module=global&section=login&do=process" method="post" id="login">
<input type="hidden" name="auth_key" value="880ea6a14ea49e853634fbdc5015a024">
<input type="hidden" name="referer" value="https://www.autohotkey.com/board/topic/66139-ahk-l-calculating-md5sha-checksum-from-file/">
<h3>Sign In</h3>
<div class="ipsBox_notice">
<ul class="ipsList_inline">
<li>
<a href="//www.autohotkey.com/board/index.php?app=core&module=global&section=login&serviceClick=facebook" class="ipsButton_secondary"><img src="//www.autohotkey.com/board/public/style_images/ortem/loginmethods/facebook.png" alt="Facebook"> Use Facebook</a>
</li>
<li>
<a href="//www.autohotkey.com/board/index.php?app=core&module=global&section=login&serviceClick=twitter" class="ipsButton_secondary"><img src="//www.autohotkey.com/board/public/style_images/ortem/loginmethods/twitter.png" alt="Twitter"> Use Twitter</a>
</li>
</ul>
</div>
<div class="ipbfs_login_row">
<div class="ipbfs_login_col">
<span class="right desc lighter blend_links"><a href="//www.autohotkey.com/board/index.php?app=core&module=global&section=register" title="Register now!">Register now!</a></span>
<strong><label for="ips_username">Username or email:</label></strong>
<div class="ipsField_content">
<input id="ips_username" type="text" class="input_text ipbfs_login_input ipbfs_luser" name="ips_username" placeholder="Username or email:" size="30" tabindex="1">
</div>
</div>
<div class="ipbfs_login_col">
<span class="right desc lighter blend_links"><a href="//www.autohotkey.com/board/index.php?app=core&module=global&section=lostpass" title="Retrieve password">I've forgotten my password</a></span>
<strong><label for="ips_password">Forum Password</label></strong>
<div class="ipsField_content">
<input id="ips_password" type="password" class="input_text ipbfs_login_input ipbfs_lpassword" name="ips_password" placeholder="Forum Password" size="30" tabindex="2"><br>
</div>
</div>
</div>
<div class="clearfix">
<div class="ipbfs_login_col">
<input type="checkbox" id="inline_remember" checked="checked" name="rememberMe" value="1" class="input_check left">
<div style="padding-left: 20px;">
<label for="inline_remember">
<strong>Remember me</strong>
<span class="desc lighter" style="display: block; padding-top: 5px;">This is not recommended for shared computers</span>
</label>
</div>
</div>
<div class="ipbfs_login_col">
<input type="checkbox" id="inline_invisible" name="anonymous" value="1" class="input_check left">
<div style="padding-left: 20px;">
<label for="inline_invisible">
<strong>Sign in anonymously</strong>
<span class="desc lighter" style="display: block; padding-top: 5px;">Don't add me to the active users list</span>
</label>
</div>
</div>
</div>
<div class="ipsForm_submit ipsForm_center clear">
<input type="submit" class="input_submit" value="Sign In">
</div>
</form>
Text Content
Jump to content * Sign In * Create Account * Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate * AutoHotkey * Forums * Members Search Advanced This topic * Search section: * This topic * Forums * Members * Help Files FacebookTwitter 1. AutoHotkey Community 2. AutoHotkey 3. Scripts and Functions * View New Content Javascript Disabled Detected You currently have javascript disabled. Several functions may not work. Please re-enable javascript to access full functionality. [AHK_L] CALCULATING MD5,SHA CHECKSUM FROM FILE Started by Deo , Apr 24 2011 03:22 PM * Please log in to reply 7 replies to this topic Deo * Members * 199 posts * Last active: Jan 31 2014 03:19 PM * Joined: 16 May 2010 hello all Here is a small function to calculate following hashes from file: [*:15azjkd4]MD2 [*:15azjkd4]MD5 [*:15azjkd4]SHA1 [*:15azjkd4]SHA256 [*:15azjkd4]SHA384 [*:15azjkd4]SHA512Current code requires AHK_L, but can be converted for using with common ahk build. filePath := "C:\Windows\notepad.exe" msgbox % "MD5:`n" HashFile(filePath,2) msgbox % "SHA:`n" HashFile(filePath,3) msgbox % "SHA512:`n" HashFile(filePath,6) /* HASH types: 1 - MD2 2 - MD5 3 - SHA 4 - SHA256 - not supported on XP,2000 5 - SHA384 - not supported on XP,2000 6 - SHA512 - not supported on XP,2000 */ HashFile(filePath,hashType=2) { PROV_RSA_AES := 24 CRYPT_VERIFYCONTEXT := 0xF0000000 BUFF_SIZE := 1024 * 1024 ; 1 MB HP_HASHVAL := 0x0002 HP_HASHSIZE := 0x0004 HASH_ALG := hashType = 1 ? (CALG_MD2 := 32769) : HASH_ALG HASH_ALG := hashType = 2 ? (CALG_MD5 := 32771) : HASH_ALG HASH_ALG := hashType = 3 ? (CALG_SHA := 32772) : HASH_ALG HASH_ALG := hashType = 4 ? (CALG_SHA_256 := 32780) : HASH_ALG ;Vista+ only HASH_ALG := hashType = 5 ? (CALG_SHA_384 := 32781) : HASH_ALG ;Vista+ only HASH_ALG := hashType = 6 ? (CALG_SHA_512 := 32782) : HASH_ALG ;Vista+ only f := FileOpen(filePath,"r","CP0") if !IsObject(f) return 0 if !hModule := DllCall( "GetModuleHandleW", "str", "Advapi32.dll", "Ptr" ) hModule := DllCall( "LoadLibraryW", "str", "Advapi32.dll", "Ptr" ) if !dllCall("Advapi32\CryptAcquireContextW" ,"Ptr*",hCryptProv ,"Uint",0 ,"Uint",0 ,"Uint",PROV_RSA_AES ,"UInt",CRYPT_VERIFYCONTEXT ) Goto,FreeHandles if !dllCall("Advapi32\CryptCreateHash" ,"Ptr",hCryptProv ,"Uint",HASH_ALG ,"Uint",0 ,"Uint",0 ,"Ptr*",hHash ) Goto,FreeHandles VarSetCapacity(read_buf,BUFF_SIZE,0) hCryptHashData := DllCall("GetProcAddress", "Ptr", hModule, "AStr", "CryptHashData", "Ptr") While (cbCount := f.RawRead(read_buf, BUFF_SIZE)) { if (cbCount = 0) break if !dllCall(hCryptHashData ,"Ptr",hHash ,"Ptr",&read_buf ,"Uint",cbCount ,"Uint",0 ) Goto,FreeHandles } if !dllCall("Advapi32\CryptGetHashParam" ,"Ptr",hHash ,"Uint",HP_HASHSIZE ,"Uint*",HashLen ,"Uint*",HashLenSize := 4 ,"UInt",0 ) Goto,FreeHandles VarSetCapacity(pbHash,HashLen,0) if !dllCall("Advapi32\CryptGetHashParam" ,"Ptr",hHash ,"Uint",HP_HASHVAL ,"Ptr",&pbHash ,"Uint*",HashLen ,"UInt",0 ) Goto,FreeHandles SetFormat,integer,Hex loop,%HashLen% { num := numget(pbHash,A_index-1,"UChar") hashval .= substr((num >> 4),0) . substr((num & 0xf),0) } SetFormat,integer,D FreeHandles: f.Close() DllCall("FreeLibrary", "Ptr", hModule) dllCall("Advapi32\CryptDestroyHash","Ptr",hHash) dllCall("Advapi32\CryptReleaseContext","Ptr",hCryptProv,"UInt",0) return hashval } anything you can improve - please do this #1 - Posted 24 April 2011 - 03:22 PM Crypt|QMsgBox|PUM|Quick Cliq|WinClipboard * Back to top -------------------------------------------------------------------------------- * Guests * Last active: * Joined: -- Weird... no replies here. I wanted to use these, can anyone confirm their autenticity? #2 - Posted 10 July 2011 - 04:22 PM * Back to top -------------------------------------------------------------------------------- Rseding91 * Members * 703 posts * Last active: Apr 02 2016 05:05 AM * Joined: 07 Jun 2010 > Weird... no replies here. > > I wanted to use these, can anyone confirm their autenticity? The code is right there. Read it and try it out - i'm not sure how one would prove if it's authentic or not. #3 - Posted 10 July 2011 - 05:53 PM (Statistics script) M&K Counter 2.0 My FAST ini Lib GDI+ all in one for Basic, L ANSI, L Unicode x86 and L Unicode x64 * Back to top -------------------------------------------------------------------------------- dwype * Guests * Last active: * Joined: -- i think the person was asking if it works. it works very well, thank you! #4 - Posted 20 August 2011 - 09:28 PM * Back to top -------------------------------------------------------------------------------- Cragaha * Members * 265 posts * Last active: Jan 04 2016 02:24 AM * Joined: 19 Nov 2010 Thanks for the function Deo, I made a test script to test yours against hashes.dll, I thought that dll will be much faster, couldn't be more wrong, yours is 1.5 times faster #5 - Posted 18 November 2011 - 09:56 PM http://ahkscript.org/ * Back to top -------------------------------------------------------------------------------- sumon * Moderators * 1317 posts * Last active: Dec 05 2016 10:14 PM * Joined: 18 May 2010 Thanks for a very useful function, I think I might try to find some use of this soon (for handling remoteResource() file versions), or maybe even for handling StdLib. I made two very simple changes. I added support for inputting the name of the hashType, and I renamed the subroutine to make it "unique" (minimizing risk of conflicting with another function or script). So now you could do MsgBox % HashFile(filePath, "MD5") HashFile(filePath,hashType=2) ; By Deo, http://www.autohotkey.com/forum/viewtopic.php?t=71133 { PROV_RSA_AES := 24 CRYPT_VERIFYCONTEXT := 0xF0000000 BUFF_SIZE := 1024 * 1024 ; 1 MB HP_HASHVAL := 0x0002 HP_HASHSIZE := 0x0004 HASH_ALG := (hashType = 1 OR hashType = "MD2") ? (CALG_MD2 := 32769) : HASH_ALG HASH_ALG := (hashType = 2 OR hashType = "MD5") ? (CALG_MD5 := 32771) : HASH_ALG HASH_ALG := (hashType = 3 OR hashType = "SHA") ? (CALG_SHA := 32772) : HASH_ALG HASH_ALG := (hashType = 4 OR hashType = "SHA256") ? (CALG_SHA_256 := 32780) : HASH_ALG ;Vista+ only HASH_ALG := (hashType = 5 OR hashType = "SHA384") ? (CALG_SHA_384 := 32781) : HASH_ALG ;Vista+ only HASH_ALG := (hashType = 6 OR hashType = "SHA512") ? (CALG_SHA_512 := 32782) : HASH_ALG ;Vista+ only f := FileOpen(filePath,"r","CP0") if !IsObject(f) return 0 if !hModule := DllCall( "GetModuleHandleW", "str", "Advapi32.dll", "Ptr" ) hModule := DllCall( "LoadLibraryW", "str", "Advapi32.dll", "Ptr" ) if !dllCall("Advapi32\CryptAcquireContextW" ,"Ptr*",hCryptProv ,"Uint",0 ,"Uint",0 ,"Uint",PROV_RSA_AES ,"UInt",CRYPT_VERIFYCONTEXT ) Gosub,HashTypeFreeHandles if !dllCall("Advapi32\CryptCreateHash" ,"Ptr",hCryptProv ,"Uint",HASH_ALG ,"Uint",0 ,"Uint",0 ,"Ptr*",hHash ) Gosub, HashTypeFreeHandles VarSetCapacity(read_buf,BUFF_SIZE,0) hCryptHashData := DllCall("GetProcAddress", "Ptr", hModule, "AStr", "CryptHashData", "Ptr") While (cbCount := f.RawRead(read_buf, BUFF_SIZE)) { if (cbCount = 0) break if !dllCall(hCryptHashData ,"Ptr",hHash ,"Ptr",&read_buf ,"Uint",cbCount ,"Uint",0 ) Gosub, HashTypeFreeHandles } if !dllCall("Advapi32\CryptGetHashParam" ,"Ptr",hHash ,"Uint",HP_HASHSIZE ,"Uint*",HashLen ,"Uint*",HashLenSize := 4 ,"UInt",0 ) Gosub, HashTypeFreeHandles VarSetCapacity(pbHash,HashLen,0) if !dllCall("Advapi32\CryptGetHashParam" ,"Ptr",hHash ,"Uint",HP_HASHVAL ,"Ptr",&pbHash ,"Uint*",HashLen ,"UInt",0 ) Gosub, HashTypeFreeHandles SetFormat,integer,Hex loop,%HashLen% { num := numget(pbHash,A_index-1,"UChar") hashval .= substr((num >> 4),0) . substr((num & 0xf),0) } SetFormat,integer,D HashTypeFreeHandles: f.Close() DllCall("FreeLibrary", "Ptr", hModule) dllCall("Advapi32\CryptDestroyHash","Ptr",hHash) dllCall("Advapi32\CryptReleaseContext","Ptr",hCryptProv,"UInt",0) return hashval } #6 - Posted 20 December 2011 - 09:18 AM ~sumon • APPIFYER * Back to top -------------------------------------------------------------------------------- Deo * Members * 199 posts * Last active: Jan 31 2014 03:19 PM * Joined: 16 May 2010 hello, guys, thank you for replies! check Crypt class if you interested in more features #7 - Posted 20 December 2011 - 10:14 AM Crypt|QMsgBox|PUM|Quick Cliq|WinClipboard * Back to top -------------------------------------------------------------------------------- Driedman * Members * 2 posts * Last active: Mar 06 2013 07:22 AM * Joined: 27 Jan 2013 For people who want to do file comparisons, I have made a gui that does so. I have added couple Msgboxes so you don't get confused on why (you think) it doesn't do anything after picking the file(s). By the way, I only did it for the MD5 hashes, but if you want to do it for the SHA and SHA12 hashes you can just replace where Hashfile() is with the SHA and SHA12 functions. Enjoy! Goto, Start Start: MsgBox If you want to just check a single file for it's MD5 hash.... `nChoose the file then on the second file select press cancel. FileSelectFile, TheFile, 1 2, C:, Please Select The File you want to do a hash comparison on. FileSelectFile, TheFile2, 1 1, C:, Please Select File Number 2 you wish to compare. MsgBox ---------------------------------------WARNING!----------------------------------- `n If you plan on hash checking large files, please give it time to check it. `n (1gb files usually take 10-20 seconds) `n `n If the hash shows 0, this means you did not pick a file. `n (Good for using for just one file instead of doing comparisons) Gui, Font, Bold underline Gui, add, text, x55, MD5 Hash for File 1 Gui, add, text, x55 y90, MD5 Hash for File 2 Gui, Font, Gui, add, Edit, x5 y40 ReadOnly, % HashFile(TheFile,2) Gui, add, Edit, x5 y130 ReadOnly, % HashFile(TheFile2,2) Gui, Add, Button, x55 y170 gRestart, Restart File Comparison Gui, Show, w225 h200 return ;msgbox % "SHA:`n" HashFile(filePath,3) ;msgbox % "SHA512:`n" HashFile(filePath,6) /* HASH types: 1 - MD2 2 - MD5 3 - SHA 4 - SHA256 - not supported on XP,2000 5 - SHA384 - not supported on XP,2000 6 - SHA512 - not supported on XP,2000 */ HashFile(filePath,hashType=2) { PROV_RSA_AES := 24 CRYPT_VERIFYCONTEXT := 0xF0000000 BUFF_SIZE := 1024 * 1024 ; 1 MB HP_HASHVAL := 0x0002 HP_HASHSIZE := 0x0004 HASH_ALG := hashType = 1 ? (CALG_MD2 := 32769) : HASH_ALG HASH_ALG := hashType = 2 ? (CALG_MD5 := 32771) : HASH_ALG HASH_ALG := hashType = 3 ? (CALG_SHA := 32772) : HASH_ALG HASH_ALG := hashType = 4 ? (CALG_SHA_256 := 32780) : HASH_ALG ;Vista+ only HASH_ALG := hashType = 5 ? (CALG_SHA_384 := 32781) : HASH_ALG ;Vista+ only HASH_ALG := hashType = 6 ? (CALG_SHA_512 := 32782) : HASH_ALG ;Vista+ only f := FileOpen(filePath,"r","CP0") if !IsObject(f) return 0 if !hModule := DllCall( "GetModuleHandleW", "str", "Advapi32.dll", "Ptr" ) hModule := DllCall( "LoadLibraryW", "str", "Advapi32.dll", "Ptr" ) if !dllCall("Advapi32\CryptAcquireContextW" ,"Ptr*",hCryptProv ,"Uint",0 ,"Uint",0 ,"Uint",PROV_RSA_AES ,"UInt",CRYPT_VERIFYCONTEXT ) Goto,FreeHandles if !dllCall("Advapi32\CryptCreateHash" ,"Ptr",hCryptProv ,"Uint",HASH_ALG ,"Uint",0 ,"Uint",0 ,"Ptr*",hHash ) Goto,FreeHandles VarSetCapacity(read_buf,BUFF_SIZE,0) hCryptHashData := DllCall("GetProcAddress", "Ptr", hModule, "AStr", "CryptHashData", "Ptr") While (cbCount := f.RawRead(read_buf, BUFF_SIZE)) { if (cbCount = 0) break if !dllCall(hCryptHashData ,"Ptr",hHash ,"Ptr",&read_buf ,"Uint",cbCount ,"Uint",0 ) Goto,FreeHandles } if !dllCall("Advapi32\CryptGetHashParam" ,"Ptr",hHash ,"Uint",HP_HASHSIZE ,"Uint*",HashLen ,"Uint*",HashLenSize := 4 ,"UInt",0 ) Goto,FreeHandles VarSetCapacity(pbHash,HashLen,0) if !dllCall("Advapi32\CryptGetHashParam" ,"Ptr",hHash ,"Uint",HP_HASHVAL ,"Ptr",&pbHash ,"Uint*",HashLen ,"UInt",0 ) Goto,FreeHandles SetFormat,integer,Hex loop,%HashLen% { num := numget(pbHash,A_index-1,"UChar") hashval .= substr((num >> 4),0) . substr((num & 0xf),0) } SetFormat,integer,D FreeHandles: f.Close() DllCall("FreeLibrary", "Ptr", hModule) dllCall("Advapi32\CryptDestroyHash","Ptr",hHash) dllCall("Advapi32\CryptReleaseContext","Ptr",hCryptProv,"UInt",0) return hashval } Restart: TheFile = "" TheFile2 = "" Gui, Destroy goto, Start return GuiClose: ExitApp #8 - Posted 27 February 2013 - 11:26 PM * Back to top -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- Back to Scripts and Functions Reply to quoted posts Clear 1. AutoHotkey Community 2. → AutoHotkey 3. → Scripts and Functions Community Forum Software by IP.Board Licensed to: AutoHotkey Foundation LLC * * main * all * forumbot * Change Theme * IP.Board * IP.Board Mobile * Ortem * English (USA) * English (USA) * Deutsch * Privacy Policy * Help SIGN IN * Use Facebook * Use Twitter Register now! Username or email: I've forgotten my password Forum Password Remember me This is not recommended for shared computers Sign in anonymously Don't add me to the active users list