Okay I am screwing around with web sockets and am trying to negotiate a connection but I have to do some math to generate a proper negotiation.
draft-ietf-hybi-thewebsocketprotocol-03 - The WebSocket protocol That is the RFC I am referencing.
Okay I have the following information:
First step is removing all non-numeric characters from key1 and key 2 leaving me with.Code:Key1: 18x 6]8vM;54 *(5: { U1]8 z [ 8 Key2: 1_ tx7X d < nw 334J702) 7]o}` 0 Final: Tm[K T2u
I used a simple regex for that [^[0-9]] that worked fineCode:Key1: 1868545188 Key2: 1733470270
Next I have to calculate the spaces in the original key1 and key 2 which I did sucesfully with a foreach statement.
Key1 spaces = 12
Key2 spaces = 10
Now heres the part I am not sure of and need help on. I need to divide the key1 number by the number of spaces
1868545188 / 12 155712099
1733470270 / 10 173347027
I need to express each of these output as Big Endian 32 bit numbers? Does that mean flip them? how would I do that in C#.
After that I concatenate the two numbers with the Final and get the md5 sum of that. Again how do I do this in c#. I am currently doing it this way:
If you guys could help me out I would appreciate it. Note the final outcome of those calculations should be a 16 byte 128 bit value, which in this case is: fQJ,fN/4F4!~K~MHCode:MD5CryptoServiceProvider x = new MD5CryptoServiceProvider(); byte[] output = x.ComputeHash(input); string MD5Output = ASCIIEncoding.UTF8.GetString(output);