# My Hash function

## Recommended Posts

I made an hash function similar to MD5.

Here's my script:

While 1
\$exemple = Inputbox ( "Hash", "Type a message", "", "", -1, 100, -1, -1 )
Msgbox ( 0, "Hash", hash(\$exemple ))
WEnd

Func hash(\$string)
Dim \$k[64]
Dim \$r[64] = [7, 12, 17, 22,  7, 12, 17, 22,  7, 12, 17, 22,  7, 12, 17, 22, 5, 9, 14, 20,  5,  9, 14, 20,  5,  9, 14, 20,  5,  9, 14, 20, 4, 11, 16, 23,  4, 11, 16, 23,  4, 11, 16, 23, 4, 11, 16, 23, 6, 10, 15, 21, 6, 10, 15, 21,  6, 10, 15, 21,  6, 10, 15, 21]
Local \$h0 = 0x67452301
Local \$h1 = 0xEFCDAB89
Local \$h3 = 0x10325476
Local \$w = __MessageInit ( \$string )

\$a = \$h0
\$b = \$h1
\$c = \$h2
\$d = \$h3

For \$i = 0 to 63
\$k[\$i] = Floor(Abs(Sin(\$i + 1)) * 2^32)
Next
For \$loop = 1 to 16
For \$i = 0 to 63
If 0 < \$i < 15 Then
\$f = BitOr(BitAND ( \$b, \$c ), BitAnd(BitNOT ( \$b ), \$d))
\$g = \$i
ElseIf 16 < \$i < 31 Then
\$f = BitOr ( BitAnd ( \$d, \$b ), BitAnd ( BitNot ( \$d ), \$c ) )
\$g = Mod (5*\$i+1, 16 )
ElseIf 32 < \$i < 47 Then
\$f = BitXOR ( \$b, \$c, \$d )
\$g = Mod ( 3*\$i + 5, 16 )
Elseif 48 < \$i < 63 Then
\$f = BitXOR ( \$c, BitOr ( \$b, BitNOT ( \$d ) ) )
\$g = Mod (7*\$i, 16)
EndIf

\$temp = \$d
\$d = \$c
\$c = \$b
\$b = BitRotate (\$a + \$f + \$k[\$i] + \$w[\$g], \$r[\$i]) + \$b
\$a = \$temp
Next
\$h0 = \$h0 + \$a
\$h1 = \$h1 + \$b
\$h2 = \$h2 + \$c
\$h3 = \$h3 + \$d
Next
Return Hex(Abs(\$h0))&Hex(Abs(\$h1))&Hex(Abs(\$h2))&Hex(Abs(\$h3))

EndFunc

Func __MessageInit(\$message)
Dim \$new [65535]
Dim \$rt[64]
Local \$tmp = 64

For \$i = 0 to StringLen ( \$message )
\$new[\$i] = Asc( StringMid (\$message, \$i+1, 1 ) )
Next
If StringLen ( \$message ) < 64 Then
For \$i = 0 to 63
If \$new[\$i] <> "" Then
\$rt[\$i] = \$new[\$i]
Else
\$rt[\$i] = 0
EndIf
Next
Return \$rt
EndIf

For \$i = 0 to StringLen ( \$message )
If \$i >= \$tmp+64 Then \$tmp = \$tmp+64

If \$i > 63 Then
\$rt[\$i-\$tmp] = BitXOR ( \$new[\$i], \$rt[\$i-\$tmp] )
Else
\$rt[\$i] = \$new[\$i]
EndIf
Next
Return \$rt
EndFunc

Exemple:

This is a test.

This is a rest.

601174114165187C24F793148F7FB45F

Edited by Joke758

[u]My Programs:[/u]Word Search Creator - Make your own Word SearchShortHand - Hide a secret message in a jpg fileHex Editor - Edit your Binary fileIncrease file size - Increase the size of any filesArt Generator - A program that generate random picture[u]My Functions:[/u]16-Bits Hash - My Hash function similar to MD5Probabilities - My probabilities function (factorial, permuation, combination)_GetDate() - Convert a date to a day of the week_Base(), _Dec() - Convert a number in any base (bin, oct, hex, dec). Create your own!

##### Share on other sites

Very nice! Too bad MD5 is outdated.

##### Share on other sites

Very nice! Too bad MD5 is outdated.

@Manadar: MD5 is outdated? I'm sure you can explain why and in which circumstances...

@Joke758: Can you mathematically prove, that your hash function is cryptographically as strong as MD5 and/or SHA-1? If you cannot do that, I recommend these articles: http://www.securius.com/newsletters/Snake_...Encryption.html AND http://www.schneier.com/crypto-gram-9902.html

Cheers

Kurt

Edited by /dev/null

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

##### Share on other sites

@Manadar: MD5 is outdated? I'm sure you can explain why and in which circumstances...

You just named the reasons why MD5 is outdated. MD5 has inherit flaws. I've only just noticed that he said his script was not exactly MD5, so he may have gotten rid of those flaws. However, it looks more like a rebuild of MD5.

## Create an account

Register a new account

• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...