| View previous topic :: View next topic |
| Author |
Message |
Sean
Joined: 12 Feb 2007 Posts: 2462
|
Posted: Wed Sep 26, 2007 5:58 am Post subject: MD5, SHA1, CRC32 of the File |
|
|
It will calculate the hash MD5/SHA1/CRC32 of the files in any format.
NEED the standard library File.ahk.
DOWNLOAD Hash.ahk. |
|
| Back to top |
|
 |
majkinetor
Joined: 24 May 2006 Posts: 4511 Location: Belgrade
|
Posted: Wed Sep 26, 2007 7:18 am Post subject: |
|
|
Thx.
I wonder why didn't u united in the one function that takes parameter for desired hash type _________________
 |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2462
|
Posted: Wed Sep 26, 2007 8:45 am Post subject: |
|
|
| 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. |
|
| Back to top |
|
 |
majkinetor
Joined: 24 May 2006 Posts: 4511 Location: Belgrade
|
Posted: Wed Sep 26, 2007 8:55 am Post subject: |
|
|
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. _________________
 |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2462
|
Posted: Wed Sep 26, 2007 11:19 am Post subject: |
|
|
| 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. |
|
| Back to top |
|
 |
Laszlo
Joined: 14 Feb 2005 Posts: 4710 Location: Boulder, CO
|
Posted: Wed Sep 26, 2007 6:49 pm Post subject: |
|
|
| 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. |
|
| Back to top |
|
 |
majkinetor
Joined: 24 May 2006 Posts: 4511 Location: Belgrade
|
Posted: Wed Sep 26, 2007 7:42 pm Post subject: |
|
|
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. _________________
 |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2462
|
Posted: Thu Sep 27, 2007 12:45 am Post subject: |
|
|
| 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. |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2462
|
Posted: Thu Sep 27, 2007 12:49 am Post subject: |
|
|
| 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
|
|
|
| Back to top |
|
 |
A-BitsCode Guest
|
Posted: Fri Jan 18, 2008 7:07 pm Post subject: Compatibility |
|
|
| 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. |
|
| Back to top |
|
 |
A-BitsCode Guest
|
Posted: Fri Jan 18, 2008 7:33 pm Post subject: Compatibility |
|
|
When running the function inside a remote desktop session, I get this result:
[img]http://www-server.info/ahk/remote_desktop.bmp[/img]
When running the function on the same computer but inside a normal session, I get this result:
[img]http://www-server.info/ahk/normal_mode.bmp[/img]
Any help would be appreciated. |
|
| Back to top |
|
 |
quatermass
Joined: 14 Dec 2005 Posts: 216
|
Posted: Wed Dec 03, 2008 1:13 pm Post subject: Sean's - MD5, SHA1, CRC32 of the File |
|
|
| 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 |
|
| Back to top |
|
 |
|