Jump to content

hashes.dll script


Recommended Posts

i got bored.. so i made a little udf

it uses a dll file available here, (Download) that retrieves a files/string checksum, and supports a crapload of hashes

"Supported the following HASHES:

MD2,MD4,MD5,SHA1,SHA256,SHA384,SHA512,HAVAL128,HAVAL160,HAVAL192,HAVAL224,HAVAL256

GHOST,TIGER128,TIGER160,TIGER192,RIPE-MD128,RIPE-MD160,CRC32,CRC16,ARC-CRC"

Update: Added better error checking, added another example..

Update: Now support strings and files.. :)

#cs
    This DLL is free for non commercial use. 
    My site: http://www.paehl.de
    Supported the following HASHES:
    MD2,MD4,MD5,SHA1,SHA256,SHA384,SHA512,HAVAL128,HAVAL160,HAVAL192,HAVAL224,HAVAL256
    GHOST,TIGER128,TIGER160,TIGER192,RIPE-MD128,RIPE-MD160,CRC32,CRC16,ARC-CRC
#ce

;Example-Strings SHA1
Local $s[2], $h[3], $DLLHashes = DllOpen('hashes.dll')

;written
$s[0] = 'Hello World'
$h[0] = _Hashes($s[0], 'SHA1', $DLLHashes)

;rechecked
$h[1] = _Hashes($s[0], 'SHA1', $DLLHashes)

;modified
$s[1] = StringLower($s[0])
$h[2] = _Hashes($s[1], 'SHA1', $DLLHashes)

ConsoleWrite($s[0] &@LF& $h[0] &@lf& $h[1] &@lf& $s[1] &@lf& $h[2] &@lf&@lf)

;Example-File SHA1

$s[1] = @AutoItExe
$h[0] = _Hashes($s[1], 'SHA1', $DLLHashes, 1)

ConsoleWrite($s[1] &@lf& $h[0] &@lf&@lf)

;Hash test
ConsoleWrite('Hash test' &@lf)
$s[1] = 'abcdefghijklmnopqrstuvwxyz'
$shash = StringSplit('MD2,MD4,MD5,SHA1,SHA256,SHA384,SHA512,HAVAL128,HAVAL160,HAVAL192,HAVAL224,HAVAL256,'& _
                    'GHOST,TIGER128,TIGER160,TIGER192,RIPE-MD128,RIPE-MD160,CRC32,CRC16,ARC-CRC',',')
For $y = 1 to $shash[0]
    ConsoleWrite('String:'& $s[1] &': Hash-'& $shash[$y] &':'& _Hashes($s[1], $shash[$y], $DLLHashes, 0) & @lf)
Next

;------------------------------------
;$sValue = string or file (need to set sfile = 0 for string, sfile = 1 for file)
;$sHash = hash algorthm
;$DLLHashes = the dll location or handle
;$sFile = 0 = string [default], 1 = file
;------------------------------------
Func _Hashes($sValue, $sHash = 'MD5', $DLLHashes = 'hashes.dll', $sFile = 0)
    Local $aValue[1], $sSplit, $hashes = Random(-100,100) & 'hashes.txt'
    If $sFile = 1 And FileExists($sValue) Then $hashes = $sValue
    If $sFile = 0 Then FileWrite($hashes,$sValue) ;seems to only want files so well write a temp one
    $aValue = DllCall($DLLHashes, 'str', 'testit', 'str', $hashes, 'str',$sHash, 'int', false)
    If $sFile = 0 Then FileDelete($hashes) ;then delete it
    If Not @error And IsArray($aValue) Then
        $sSplit = StringSplit($aValue[0],@LF) ;extract hash string
        If Not @error Then $aValue[0] = StringTrimRight($sSplit[1],1) 
        If StringInStr($aValue[0],'Error:') Then Return SetError(1,0,0)
        Return $aValue[0]
    EndIf
    SetError(1,0,0)
EndFunc
Edited by mrRevoked
Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()
Link to comment
Share on other sites

Looks cool but I cant see too many uses for this. I could be wrong.

[center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center]

Link to comment
Share on other sites

Thank You mrRevoked and nice work. I used this script for hashing over 300 bios files. It was usefull :)

Looks cool but I cant see too many uses for this. I could be wrong.

Yep your wrong ! :D lol

I admit that I don't hash strings and files on a hourly basis, but I do use hashing functions on regular occasions.

@ mrRevoked

Your scripts aren't useless and your script writing style is great and getting greater all the time.

I've silently learnt things from post snippets of your scripts around the forums.

Please don't refrain :D

Cheers

Link to comment
Share on other sites

I am curious would you run a test on the time it takes to create the hashes in comparison with my FileString Hash plugin in my signature?

I haven't been as active on the forums, so I dont think as many people know about my plugin anymore. I am just trying to see if I need to further optimize the code I have in my plugin.

Thanks,

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

Hi JSThePatriot and thank you.

Your hash plugin is the first hash plugin I used when I needed to hash some files some time back and it's a pleasure to use.

I found it to be fast and stable.

I haven't compared mrRevoked and your plugin in a speed test yet.

The dll that mrRevoked uses with his udf is 37kb in size and supports alot of differant types of hashing.

(most of which I'll probly never use..lol)

So I thought why not give it a go since I had a few hundred bios files I needed to identify I may as well give his script a go.

Must admit hashing of 300+ files @ 256kb - 1024kb in size went by pretty quick without any fuss, but I didn't actually log the time it took.

Cheers.

Link to comment
Share on other sites

Hi JSThePatriot and thank you.

Your hash plugin is the first hash plugin I used when I needed to hash some files some time back and it's a pleasure to use.

I found it to be fast and stable.

I haven't compared mrRevoked and your plugin in a speed test yet.

The dll that mrRevoked uses with his udf is 37kb in size and supports alot of differant types of hashing.

(most of which I'll probly never use..lol)

So I thought why not give it a go since I had a few hundred bios files I needed to identify I may as well give his script a go.

Must admit hashing of 300+ files @ 256kb - 1024kb in size went by pretty quick without any fuss, but I didn't actually log the time it took.

Cheers.

I love to see people developing with AutoIt. I know my plugin is a bit slow in some places. Not to mention the size of my DLL seems a bit larger for some reason, and it only has two of the hash formats. I am just interested in if there is a speed difference. There seems to be a bigger speed difference with mine after more operations than with small short operations. (That atleast gives me an idea of where to start looking)

Thanks,

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

  • 4 weeks later...
  • 2 weeks later...

I did some MD5 speed tests and it seems that this hashes.dll plugin is faster for most files. It was slower on really small files though.

Here's the code I used for testing. Just change the paths to your dll files in this script. It makes a MD5.log file in your @ScriptDir with the File/Path, MD5 Hash code, and the amount of time it took.

CODE
$dllIs = "C:\trash\hashes_dll\hashes.dll"

$dll2Is = "C:\trash\hashes_dll\f-shash.dll"

$GetFile = FileOpenDialog('Get Files', '', "Files (*.*)", 1 + 4 ) ; LNG - Hold down Ctrl or Shift to choose multiple RVMAddons.

If $GetFile = '' Then Exit

$DLLHashes = DllOpen($dllIs)

$plHND = PluginOpen($dll2Is)

$Split = StringSplit($GetFile, '|')

If Not @error Then

FileDelete(@ScriptDir&'\md5.log')

For $i = 2 to $Split[0]

MrRevoked($Split[1]&'\'&$Split[$i])

JSThePatriot($Split[1]&'\'&$Split[$i])

Next

Else

MrRevoked($GetFile)

JSThePatriot($GetFile)

EndIf

DllClose($DLLHashes)

PluginClose($plHND)

Func MrRevoked($file)

$Timerinit = TimerInit()

$mymd5 = _Hashes($file, 'MD5', $dllIs, 1)

$Amount = TimerDiff($Timerinit)

Logg('MrRevoked:'&@CRLF&$file&@CRLF&$mymd5&@CRLF&$Amount&@CRLF&@CRLF)

EndFunc

Func JSThePatriot($file)

$Timerinit = TimerInit()

$mymd5 = MD5Check($file)

$Amount = TimerDiff($Timerinit)

Logg('JSThePatriot:'&@CRLF&$file&@CRLF&$mymd5&@CRLF&$Amount&@CRLF&@CRLF)

EndFunc

Func Logg($String)

FileWriteLine(@ScriptDir&'\md5.log', $String)

EndFunc

;------------------------------------

;$sValue = string or file (need to set sfile = 0 for string, sfile = 1 for file)

;$sHash = hash algorthm

;$DLLHashes = the dll location or handle

;$sFile = 0 = string [default], 1 = file

;------------------------------------

Func _Hashes($sValue, $sHash = 'MD5', $DLLHashes = 'hashes.dll', $sFile = 0)

Local $s[2], $h[3]

Local $aValue[1], $sSplit, $hashes = Random(-100,100) & 'hashes.txt'

If $sFile = 1 And FileExists($sValue) Then $hashes = $sValue

If $sFile = 0 Then FileWrite($hashes,$sValue) ;seems to only want files so well write a temp one

$aValue = DllCall($DLLHashes, 'str', 'testit', 'str', $hashes, 'str',$sHash, 'int', false)

If $sFile = 0 Then FileDelete($hashes) ;then delete it

If Not @error And IsArray($aValue) Then

$sSplit = StringSplit($aValue[0],@LF) ;extract hash string

If Not @error Then $aValue[0] = StringTrimRight($sSplit[1],1)

If StringInStr($aValue[0],'Error:') Then Return SetError(1,0,0)

Return StringUpper($aValue[0])

EndIf

SetError(1,0,0)

EndFunc

Func MD5Check($file)

$md5File = StringUpper(FileHash($file, 1))

Return $md5File

EndFunc

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...