Sign in to follow this  
Followers 0
Ward

The Ultimately Hash Solution

19 posts in this topic

#1 ·  Posted (edited)

Here are already too many hash UDF. However, I hope this one is the simplest and the fast.

These algorithms are written by Projet RNRT SAPHIR (except CRC32, Alder, GOST), modify and compile to DLL by me.

And I use MemoryDLL UDF to let the DLL work like a pure script.

This UDF only have two functions: _Hash($Type, $Data), and _HashFile($Type, $File)

Where $Type is a string to specify what algorithm to use, for example, "md5" or "sha1"

Hash39.au3 and Hash9.au3 are identical except the DLL used by Hash39.au3 has more algorithms.

The algorithms list:

Hash9: MD5, SHA1, SHA224, SHA256, SHA384, SHA512, CRC16, CRC32, and ADLER32.

Hash39: All in Hash9 plus MD2, MD4, ED2K, PANAMA, RIPEMDn(n = 128, 160, 256, 320), SHA0(original SHA), TIGER, TIGER2(Tiger with a modified padding), WHIRLPOOL(2003), WHIRLPOOL0(2000), WHIRLPOOL1(2001), GOST, and HAVALn_m(n = 128, 160, 192, 224, 256; m = 3, 4, 5, for example: HAVAL128_3)

Hash39DLL.au3 and Hash9Dll.au3 are the alternative version. They don't use MemoryDLL UDF.

An example:

#include "Hash39.au3"

$Timer = TimerInit()
$Hash = _Hash("md5", "The quick brown fox jumps over the lazy dog")
MsgBox(0, TimerDiff($Timer), $Hash)

$Timer = TimerInit()
$Hash = _Hash("sha1", "The quick brown fox jumps over the lazy dog")
MsgBox(0, TimerDiff($Timer), $Hash)

$Timer = TimerInit()
$Hash = _Hash("haval128_3", "The quick brown fox jumps over the lazy dog")
MsgBox(0, TimerDiff($Timer), $Hash)

$Timer = TimerInit()
$Hash = _Hash("whirlpool", "The quick brown fox jumps over the lazy dog")
MsgBox(0, TimerDiff($Timer), $Hash)

2008/09/28 Update Note:

Fix a major bug that may cause crash.

Add GOST hash algorithm.

2008/12/06 Update Note:

Add some algorithm.

Less size and more speed.

Update MemoryDll.au3, now worked under Vista.

Hash.zip

Edited by Ward

新版 _ArrayAdd 的白痴作者,不管是誰,去死一死好了

 

Share this post


Link to post
Share on other sites



Doesn't work. The returned value is not an array. The Hash call fails.

Share this post


Link to post
Share on other sites

Doesn't work. The returned value is not an array. The Hash call fails.

The returned value shoud be a string in HEX format, not an array.

May be you can post your code, and then I can test and see what's wrong.


新版 _ArrayAdd 的白痴作者,不管是誰,去死一死好了

 

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

No, is what im saying is that after your DllCall, you have Return $Ret[0], $Ret isn't an error, so it fails, saying....blah you know.

EDIT: I'm using your example in your zip.

Edited by Alienware

Share this post


Link to post
Share on other sites

You mean DllCall or MemoryDllCall? The hash script don't use any build-in DllCall.


新版 _ArrayAdd 的白痴作者,不管是誰,去死一死好了

 

Share this post


Link to post
Share on other sites

This function.

Func _Hash($Type, $Data)
    If Not IsNumber($__HashDll) Then $__HashDll = MemoryDllOpen($__HashDllCode)

    Local $Buffer = DllStructCreate('byte[' & BinaryLen($Data) & ']')
    DllStructSetData($Buffer, 1, $Data)

    Local $Ret = MemoryDllCall($__HashDll, "str", "hash", "str", $Type, "ptr", DllStructGetPtr($Buffer), "uint", BinaryLen($Data))
    Return $Ret[0]
EndFunc

It Cannot Return an Array, because $Ret is not an array.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

So what you mean is MemoryDllCall.....

Do you have tested other script using MemoryDllCall? Or even machine code?

I don't know if MemoryDllCall work under vista. Because I don't have a vista system to test.

If it is not, maybe you can only use them as a normal DLL. But it no more a pure scirpt.

I upload a normal DLL version, you can test it.

Edited by Ward

新版 _ArrayAdd 的白痴作者,不管是誰,去死一死好了

 

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Wow very nice job! Impressive amount of algorithms :)

Tested working on..

Windows XP Professional SP2

Windows Vista Home Premium

A few questions.. Why is there so many HAVAL functions? and could you post the source code for the Hash36.dll and Hash8.dll?

CODE

HAVAL128_3

HAVAL128_4

HAVAL128_5

HAVAL160_3

HAVAL160_4

HAVAL160_5

HAVAL192_3

HAVAL192_4

HAVAL192_5

HAVAL224_3

HAVAL224_4

HAVAL224_5

HAVAL256_3

HAVAL256_4

HAVAL256_5

MD2

MD4

MD5

PANAMA

RIPEMD128

RIPEMD160

RIPEMD

SHA0

SHA1

SHA224

SHA256

SHA384

SHA512

TIGER2

TIGER

WHIRLPOOL0

WHIRLPOOL1

WHIRLPOOL

CRC32

ADLER32

GOST

Edited by mrRevoked

Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Alienware is right, the machine code version does not work on Vista, But it works just fine on Windows XP... :)

Edited by mrRevoked

Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()

Share this post


Link to post
Share on other sites

Haval is the generic function, it supports multiple output lengths, as well as multiple internal pass values. Lengths are 128, 160, 192, 224, 256. Passes are 3, 4, 5. That's why there's so many of those.

As to wanting source for these, just lookup the rehash project on Sourceforge, all these (except Whirlpool and Panama) are in there. A little snooping on the web will help you find the others.

If I ever get around to it, I have something similar to all this to show as well, though ward's solution will still be faster.

Share this post


Link to post
Share on other sites

A while ago I did look at rehash, it is a command line app, but it seems like converting and compiling it as a dll would be a tedious task.

It would be interesting to see these algorithms implement in AutoIt. (assuming that's what meant :))

Thanks.


Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Great dll.

Too bad that for some reason it doesn't work on Vista (MemoryDllCall). As far as I can see the problem is in this line of MemoryDll.au3:

Local $Module = DllCall($_MDKernel32Dll, "uint", $_MFHookApi, "uint", $LoadLibraryA[0], "uint", $GetProcAddress[0], "ptr", DllStructGetPtr($DllBuffer))

$Module[0] is 0

This $_MFHookApi ("LocalCompact"), is obviously crucial and it's not working with vista.(I edited this part - was trying to provoke the reaction, but nothing :) )

I like the idea of compressing the originall dll to reduce the size of the scripts.

Actually it's quite ingenious.

edit:

I tried MemoryDllCall() with other dll on vista and works fine, so it's not "LocalCompact", something else causes the problem

Edited by trancexx

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

Great dll.

Too bad that for some reason it doesn't work on Vista (MemoryDllCall). As far as I can see the problem is in this line of MemoryDll.au3:

Local $Module = DllCall($_MDKernel32Dll, "uint", $_MFHookApi, "uint", $LoadLibraryA[0], "uint", $GetProcAddress[0], "ptr", DllStructGetPtr($DllBuffer))

$Module[0] is 0

This $_MFHookApi ("LocalCompact"), is obviously crucial and it's not working with vista.(I edited this part - was trying to provoke the reaction, but nothing :) )

I like the idea of compressing the originall dll to reduce the size of the scripts.

Actually it's quite ingenious.

edit:

I tried MemoryDllCall() with other dll on vista and works fine, so it's not "LocalCompact", something else causes the problem

LocalCompact is obsolete under win32, but its entry point is still preserved for compatibility.

I just use it as a bridge between AutoIt DllCall and dll entry point. It is not the key point to the problem.

I fixed some problem at MemoryDllCall, please try it under Vista again. It should work now.


新版 _ArrayAdd 的白痴作者,不管是誰,去死一死好了

 

Share this post


Link to post
Share on other sites

LocalCompact is obsolete under win32, but its entry point is still preserved for compatibility.

I just use it as a bridge between AutoIt DllCall and dll entry point. It is not the key point to the problem.

I fixed some problem at MemoryDllCall, please try it under Vista again. It should work now.

Yes, works fine now.

Problem is solved outside autoit code?

I can see changes to assembly code used.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

Thanks for sharing it... It is really fast and so easy to use. Plus there is so many algorithms. It's really fantastic...

Is there a way to monitor the progress?? I can create a progress bar with your other Hash Tools (http://www.autoitscript.com/forum/index.php?showtopic=76976) but these are more than two times faster...

P.S:Sorry to bump an old one...

Sincerely

Tip

Edited by tip

[center]MsgBox_Tipped: Eye candy msgboxes/inputboxes/loginboxes. | CreateBlankBox: Semi-transparent layers with borders and rounded corners.[/center]

Share this post


Link to post
Share on other sites

Thanks for sharing it... It is really fast and so easy to use. Plus there is so many algorithms. It's really fantastic...

Is there a way to monitor the progress?? I can create a progress bar with your other Hash Tools (http://www.autoitscript.com/forum/index.php?showtopic=76976) but these are more than two times faster...

P.S:Sorry to bump an old one...

Sincerely

Tip

For this UDF, sorry no way to monitor the progress.

If you really want to, I cound modify this UDF. But only if I have free time to do this.


新版 _ArrayAdd 的白痴作者,不管是誰,去死一死好了

 

Share this post


Link to post
Share on other sites

Might be late but when I goto extract the .zip file my av displays TR/Crypt.XPACK.Gen is that something that is required?

Share this post


Link to post
Share on other sites

Might be late but when I goto extract the .zip file my av displays TR/Crypt.XPACK.Gen is that something that is required?

I've got the same problem, related only to Hash9.dll

Ward, can you please have a look at it?

Thanks for your help

Stefano

Share this post


Link to post
Share on other sites

Can somebody post a working hash39.dll? It still does not work on Windows 7. The problem is written in the sixth comment.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0