🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Huffman fun

posted in DruinkJournal
Published February 28, 2006
Advertisement
Well, I decided that to obfuscate things a little, I'd make the clients to my MMORPG send the username and SHA512 hashed password as on huffman encoded chunk. Mainly for fun really. I need to write a huffman encoding / decoding routine anyway, since I'll be using one for my chat messages.

So, first step was to get a hold of some test data so I can see what characters are more frequent than others. Many thanks to Mr. Evil for his reply. That gave me what I needed to build a huffman table. It's not too different from the text in a novel, just a couple of differences, which is good.

After that was done, I discovered std::priority_queue. It's awesome for building a huffman tree, since it takes half the work away.
End result is:
c: 00000m: 00001I: 0001000J: 00010010000K: 00010010001V: 00010010010|: 00010010011M: 000100101&: 000100110000\: 0001001100010Q: 0001001100011X: 000100110015: 0001001101C: 000100111b: 0001012: 000110000O: 0001100011: 0001100106: 0001100110F: 0001100111': 0001101.: 000111s: 0010n: 0011i: 0100u: 01010D: 010110000T: 010110001R: 01011001004: 0101100101!: 010110011A: 010110100>: 01011010100#: 010110101010[: 0101101010110$: 0101101010111G: 0101101011": 010110110+: 0101101110z: 0101101111f: 010111d: 01100P: 011010000=: 0110100010q: 0110100011U: 011010010007: 01101001001N: 0110100101*: 0110100110%: 0110100111000]: 0110100111001}: 01101001110100{: 01101001110101Z: 01101001110119: 01101001111v: 0110101p: 011011a: 0111o: 1000): 1001000003: 1001000010L: 1001000011j: 100100010B: 1001000110E: 1001000111?: 10010010-: 100100110S: 100100111w: 100101l: 10011t: 1010g: 101100W: 10110100008: 10110100010;: 101101000110: 101101001Y: 10110101000`: 101101010010000@: 101101010010001~: 10110101001001^: 1011010100101<: 101101010011(: 1011010101H: 1011010110_: 1011010111,: 1011011h: 10111 : 110k: 1110000x: 111000100/: 111000101:: 11100011y: 111001r: 11101e: 1111

That looks about right to me. Next step is to compile those bit values into an actual string, and then work out how to decode it all. Then I need to find out if it ends up any shorter (Probably not for username and password info, but it should for chat messages.


In other news, I'm supposed to be going into DC Studios tomorrow afternoon for "a quick overview of the project and position". However, the guy I've been E-mailing hasn't replied for the past 2 days, so I'm not sure if there's anyone particular I'm supposed to see, or if there's anything particular I should bring. So we'll see how it goes...
Previous Entry More web admin crap
Next Entry Sod Huffman...
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement
Advertisement