Sign in to follow this  
  • entries
    557
  • comments
    1237
  • views
    421068

Huffman fun

Sign in to follow this  
Evil Steve

72 views

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: 00000
m: 00001
I: 0001000
J: 00010010000
K: 00010010001
V: 00010010010
|: 00010010011
M: 000100101
&: 000100110000
\: 0001001100010
Q: 0001001100011
X: 00010011001
5: 0001001101
C: 000100111
b: 000101
2: 000110000
O: 000110001
1: 000110010
6: 0001100110
F: 0001100111
': 0001101
.: 000111
s: 0010
n: 0011
i: 0100
u: 01010
D: 010110000
T: 010110001
R: 0101100100
4: 0101100101
!: 010110011
A: 010110100
>: 01011010100
#: 010110101010
[: 0101101010110
$: 0101101010111
G: 0101101011
": 010110110
+: 0101101110
z: 0101101111
f: 010111
d: 01100
P: 011010000
=: 0110100010
q: 0110100011
U: 01101001000
7: 01101001001
N: 0110100101
*: 0110100110
%: 0110100111000
]: 0110100111001
}: 01101001110100
{: 01101001110101
Z: 0110100111011
9: 01101001111
v: 0110101
p: 011011
a: 0111
o: 1000
): 100100000
3: 1001000010
L: 1001000011
j: 100100010
B: 1001000110
E: 1001000111
?: 10010010
-: 100100110
S: 100100111
w: 100101
l: 10011
t: 1010
g: 101100
W: 1011010000
8: 10110100010
;: 10110100011
0: 101101001
Y: 10110101000
`: 101101010010000
@: 101101010010001
~: 10110101001001
^: 1011010100101
<: 101101010011
(: 1011010101
H: 1011010110
_: 1011010111
,: 1011011
h: 10111
: 110
k: 1110000
x: 111000100
/: 111000101
:: 11100011
y: 111001
r: 11101
e: 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...
Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

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