Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

MD5 function for comparing images


  • Please log in to reply
2 replies to this topic
Benny-D
  • Members
  • 1485 posts
  • Last active: Sep 27 2016 11:23 PM
  • Joined: 29 Feb 2008
Is there any MD5 hash producing function in AHK? I have two folders each one containing bunch of images (.jpg files), more than 1000 pictures in each folder. Folders are almost identical. Some images in one folder, however, are a bit different from their twins in the other one. The changes are mainly in color shades and are not visible to the human eye. I want to use MD5-hash way to compare all the files one by one and, thus, fetch the different ones.

Rseding91
  • Members
  • 703 posts
  • Last active: Apr 02 2016 05:05 AM
  • Joined: 07 Jun 2010
FileRead,File,%A_ScriptFullPath%

FileGetSize,FileSize,%A_ScriptFullPath%



MsgBox % Calc_MD5(&File,FileSize)



Calc_MD5(_VarAddress, _VarSize){

	Static Hex = "123456789ABCDEF0"

	

	Ptr := A_PtrSize ? "Ptr" : "Uint"

	, VarSetCapacity(MD5_CTX,104,0)

	, DllCall("advapi32\MD5Init",Ptr,&MD5_CTX)

	, DllCall("advapi32\MD5Update",Ptr,&MD5_CTX,Ptr,_VarAddress,"UInt",_VarSize)

	, DllCall("advapi32\MD5Final",Ptr,&MD5_CTX)

	

	Loop,16

		N := NumGet( MD5_CTX,87+A_Index,"Char"), MD5 .= SubStr(Hex,N>>4,1) . SubStr(Hex,N&15,1)

	

	Return MD5

}


Benny-D
  • Members
  • 1485 posts
  • Last active: Sep 27 2016 11:23 PM
  • Joined: 29 Feb 2008
Thanks a million, Rseding91!!!