AutoHotkey Community

It is currently May 27th, 2012, 10:28 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 12 posts ] 
Author Message
PostPosted: September 26th, 2007, 6:58 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
It will calculate the hash MD5/SHA1/CRC32 of the files in any format.

NEED the standard library File.ahk.

DOWNLOAD Hash.ahk.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 26th, 2007, 8:18 am 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
Thx.

I wonder why didn't u united in the one function that takes parameter for desired hash type

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 26th, 2007, 9:45 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
majkinetor wrote:
I wonder why didn't u united in the one function that takes parameter for desired hash type

I wasn't sure if people would like it as it uses different functions for them.
I updated the script combining them into Hash(). SID = 0 for CRC32.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 26th, 2007, 9:55 am 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
Why not using meaningfull things instead numbers:

Code:
Hash(&sData, size, "md5")
Hash(&sData, size, "crc32")
Hash(&sData, size, "sha1")


With good interface, its nice for StdLib.

EDIT:
You can also check if first parameter is not a number. If so, you can treat it as a file name, so function becomes really practical. This introuduces dependency to File.ahk unless you paste the code, however, something which isn't true now.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 26th, 2007, 12:19 pm 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
majkinetor wrote:
Why not using meaningfull things instead numbers:

I preferred numbers as then can easily use other ones too like MD2, MD4, or SHA256 etc if supported.
Anyway, I added another one Hash_str.ahk to the zip which accepts (only) the string CRC32/MD5/SHA1 as SID.

Quote:
You can also check if first parameter is not a number. If so, you can treat it as a file name, so function becomes really practical. This introuduces dependency to File.ahk unless you paste the code, however, something which isn't true now.

Making Hash() accept the file path really introduces a dependency on other script/Library even if it's not used.
In the current context, you can use any other means than File_WriteMemory() to prepare the buffer of data without dependency on unused script/Library.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 26th, 2007, 7:49 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
Cool! Sean, if you are already in the advapi32.dll, can you figure out how to call AES properly? It should work on XP, 2003 and Vista, and could give us a fast and secure encryption.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 26th, 2007, 8:42 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
How to do large files ?

Those that can't fit into memory, for instance 1GB movie. Acctually by default it can't be bigger then 64MB.
I wonder, if file is read in chunks in loop, how to sum up cheksums.


AES wuld be indeed very good to have.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 27th, 2007, 1:45 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
Laszlo wrote:
Cool! Sean, if you are already in the advapi32.dll, can you figure out how to call AES properly? It should work on XP, 2003 and Vista, and could give us a fast and secure encryption.

Let me take a look at it, but I don't have prior knowledge on it so I don't know how much work it would require.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 27th, 2007, 1:49 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
majkinetor wrote:
I wonder, if file is read in chunks in loop, how to sum up cheksums.

They support chunk of data.
It's already possible for CRC32 in its current form, but need a tweak for CryptHash... function. Can add any data anytime until CryptGetHashParam is first called.

Code:
sFile := A_AhkPath
hFile := File_CreateFile(sFile, 3, 0x80000000, 1)
sHash := 0
VarSetCapacity(sData,65535)
Loop
{
   If Not   nSize := File_ReadFile(hFile, &sData, 65536)
      Break
   sHash := Hash(&sData, nSize, 0, "0x" . sHash)
}
File_CloseHandle(hFile)

nSize := File_WriteMemory(sFile, sData1)
MsgBox, % Hash(&sData1, nSize, 0) . " : " . sHash


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Compatibility
PostPosted: January 18th, 2008, 8:07 pm 
Can someone explain to me why is this function not working on Windows XP Pro while in remote desktop session? It is running fine when logged in normal mode.


Report this post
Top
  
Reply with quote  
 Post subject: Compatibility
PostPosted: January 18th, 2008, 8:33 pm 
When running the function inside a remote desktop session, I get this result:

Image

When running the function on the same computer but inside a normal session, I get this result:

Image

Any help would be appreciated.


Report this post
Top
  
Reply with quote  
PostPosted: December 3rd, 2008, 2:13 pm 
Offline

Joined: December 14th, 2005, 3:08 pm
Posts: 219
Sean wrote:
It will calculate the hash MD5/SHA1/CRC32 of the files in any format.

NEED the standard library File.ahk.

DOWNLOAD Hash.ahk.


Just to point out that Hash.ahk isn't a library file and File.ahk seems to need the Crypt.ahk library file. :-)

_________________
Stuart Halliday


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Google [Bot] and 20 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group