Writing a simple hash function

General discussion of Warcraft 3. Threads may may be posted here if they don't fit into the other sections.

Moderator: Cheaters

User avatar
Risen
Forum Staff
Posts: 811
Joined: January 1st, 2008, 12:58 am

Writing a simple hash function

Post by Risen »

I've always wondered this - how exactly do you hash a, lets say chat string..i could never figure this out :)
Image
Wanna learn to hack maps? --> Guide
User avatar
Ozzapoo
The Flying Cow!
Posts: 2196
Joined: November 2nd, 2007, 10:34 pm
Location: Melbourne

Re: Writing a simple hash function

Post by Ozzapoo »

There isn't one way... There are lots. But, I find, the most common way is to replace each character with another character.. So for example:

I want to hash "-gold", I could do:

Replace "-" with "d"
Replace "g" with "l"
Replace "o" with "0"
Replace "l" with "g"
Replace "d" with "-". And so the string "-gold" would be hashed (sort of.... That is nowhere near correct)

And it would turn out as "dl0g-" = "-gold"

But there are other more complicated ways, this is just the very basics.
Visit Ozzapoo.net, my blog and the home of AutoCP and Cheatpack Detector!
AutoCP3 now available for free!
User avatar
Risen
Forum Staff
Posts: 811
Joined: January 1st, 2008, 12:58 am

Re: Writing a simple hash function

Post by Risen »

Ozzapoo wrote:There isn't one way... There are lots. But, I find, the most common way is to replace each character with another character.. So for example:

I want to hash "-gold", I could do:

Replace "-" with "d"
Replace "g" with "l"
Replace "o" with "0"
Replace "l" with "g"
Replace "d" with "-". And so the string "-gold" would be hashed (sort of.... That is nowhere near correct)

And it would turn out as "dl0g-" = "-gold"

But there are other more complicated ways, this is just the very basics.
Now i get it :D. Thx
Image
Wanna learn to hack maps? --> Guide
User avatar
Kryptonyte
Forum Staff
Posts: 1400
Joined: March 17th, 2008, 12:07 am

Re: Writing a simple hash function

Post by Kryptonyte »

storyyeller wrote:The purpose of a hash is to make it impossible to figure out codes solely from looking at the JASS code.
In that respect, the one posted above fails badly. But that was just an example, it's not meant for actual protection

The basic theory behind hashes is that they rely on a one way function: one that is easy to do, but near impossible to undo.

That way, when someone enters a chat string, the map calculates the hash value of the entered string (which is easy), and then compares it to the hashvalue of the code which you put into the map in advance.
If someone opens up your map and looks at the triggers, all they will see is the hash value of the code. If they want to find out the actual code, they have to undo the hash (which is near impossible).

You can try making up your own hash function. However, this runs the risk that the function you choose is actually not that hard to undo.
The best option is to use a publicly available hash function like SHA-1 or MD5. These are functions that have been widely published and analyzed for years. The brightest minds in the world have tried to break these and have not found a way yet. That's about as secure as you can get.

I'd suggest you try wikipedia or google to learn more.
He didn't ask what it is.
Image
Made by the late ILikeHacking

My quote from SKillER
Spoiler:
Chat wrote:(19:12:41) SKillER: newfags cant triforce
(19:20:30) SKillER: ▲
▲ ▲
(19:20:35) SKillER: aww
(19:20:37) FatherSpace: FAIL
(19:20:43) Kryptonyte: Wow stop failing.
(19:20:47) SKillER: ▲
▲ ▲
(19:21:41) Kryptonyte: .

. ▲
▲ ▲
(19:22:20) Kryptonyte: I guess you were right, newfags can't triforce.
(19:22:29) SKillER: . . ▲
▲ ▲
(19:23:04) SKillER: OMFG
(19:23:06) SKillER: ... THIS CHAT
(19:23:06) SKillER: !
(19:23:36) SKillER: ▲
▲ ▲
(19:23:46) SKillER: ▲
.▲ ▲
Apparently, SKillER is a newfag.
User avatar
antivirus
Member
Posts: 89
Joined: January 20th, 2009, 12:39 pm

Re: Writing a simple hash function

Post by antivirus »

Ozzapoo wrote:There isn't one way... There are lots. But, I find, the most common way is to replace each character with another character.. So for example:

I want to hash "-gold", I could do:

Replace "-" with "d"
Replace "g" with "l"
Replace "o" with "0"
Replace "l" with "g"
Replace "d" with "-". And so the string "-gold" would be hashed (sort of.... That is nowhere near correct)

And it would turn out as "dl0g-" = "-gold"

But there are other more complicated ways, this is just the very basics.
With this in the .j file will be "dl0g-" and when you type it in the game "-gold" it will work?
LoL What was i Smoking when i talked to You?
User avatar
Ozzapoo
The Flying Cow!
Posts: 2196
Joined: November 2nd, 2007, 10:34 pm
Location: Melbourne

Re: Writing a simple hash function

Post by Ozzapoo »

You're supposed to "decrypt" it first...
Visit Ozzapoo.net, my blog and the home of AutoCP and Cheatpack Detector!
AutoCP3 now available for free!
User avatar
antivirus
Member
Posts: 89
Joined: January 20th, 2009, 12:39 pm

Re: Writing a simple hash function

Post by antivirus »

Do you have the time to make a toturial on how to "decrypt" or simply you can give me a link where its explained?
LoL What was i Smoking when i talked to You?
initialD
Some Honorary Title
Posts: 1713
Joined: June 8th, 2007, 5:08 am
Title: Angry Bird

Re: Writing a simple hash function

Post by initialD »

lol....waht do you plan to do? Simply make a JASS cp unreadable?
User avatar
Dekar
Forum Drunk
Posts: 2899
Joined: January 17th, 2007, 4:22 pm
Has thanked: 1 time
Been thanked: 1 time

Re: Writing a simple hash function

Post by Dekar »

Hashes can't be used to encrypt jass code cause of their one way nature -.-
More like hiding the activator. And using md5/sha1 makes it easy to attack them, there are dozens of attacks against them.
I've used Whirlpool once I needed them, though I wouldn't lie my hand in the fire for this algorithm.
Don't pm me with Warcraft questions, this is a forum so just make a post!
In the world of thinking we are all immigrants. -Robert Nozick
storyyeller
Senior Member
Posts: 178
Joined: February 15th, 2009, 9:08 pm

Re: Writing a simple hash function

Post by storyyeller »

If you hate hashes so much, just use digital signatures or something