I've been trying to create a dc client in c#, but I can't get the key correct (Looks like this is a common problem ) The differences between my key and the one nmdc creates are only slightly different, as these examples show:
$Lock jqEXj)Y<aj6-[*Upz2yg+kXJhl?<a+n)@[=dT=SVQ8DV%K/Sbkl8KLV7(9
$Key ç±CÑ#4Vհűg÷R „´áÄ3!"@50Õ¤Tt–±f•–æPp–Ç!7æFÇ?pE7p¡ñ
Calc: ç±CÑ#4Vհűg÷R „´áÄ3!"@50Õ¤Tt–±f•–æPp–Ç!7æFÇ?pE7p¡ñ
and
Lock: Sending_key_isn't_neccessary,_key_won't_be_checked.
Key: �c° �p?ƒCà�bc¡Ñ�5²°/%DCN096%//%DCN000%//%DCN096%/a/%DCN000%/!1°U7Cà�b‚?�5²Óp£Ã°�/%DCN096%/€à¤
Calc: Ã?c° Ã?p?ƒCàÃ?bc¡Ñ”5²°/%DCN096%//%DCN000%//%DCN096%/a/%DCN000%/!1°U7CàÃ?b‚?”5²Óp£Ã°Ã?/%DCN096%/€ÃƒÂ ¤
$Lock and $Key are sniffed, Calc is my key. I have ripped the source code from the protocol found at http://www.1stleg.com/Download/Document ... dix_A.html and ported it to c#.
Any suggestions to what I can do to get the key correct? When I connect to a nmdc hub I get kicked and temp banned, I suppose this is because the key is incorrect? Any help would be appreciated!
Tom
My implementation looks like this:
Code: Select all
public string CreateKey (string Lock)
{
const int MAX_CHARS_IN_KEY = 256 ;
char [] key = new char [MAX_CHARS_IN_KEY] ;
char [] charlock ;
charlock = Lock.ToCharArray () ;
int length = Lock.Length ;
StringBuilder sKey = new StringBuilder (MAX_CHARS_IN_KEY) ;
// Calculating chars in key
for (int i = 1; i < length; i++)
{
key[i] = (char) ((int) charlock[i] ^ (int) charlock[i-1]);
}
// Calculating first char in key
key[0] = (char) ((int) charlock[0] ^ (int) charlock[length-1] ^ (int) charlock[length-2] ^ 5) ;
// Nibble-swap every char in key
for (int i = 0; i < length; i++)
{
key[i] = (char) ((( (int) key[i]<<4) & 240) | (( (int) key[i]>>4) & 15)) ;
}
// DCN encoding special chars
for (int i = 0; i < length; i++)
{
switch (key [i])
{
case (char) 0:
sKey.Append ("/%DCN000%/") ;
break ;
case (char) 5:
sKey.Append ("/%DCN005%/") ;
break ;
case (char) 36:
sKey.Append ("/%DCN036%/") ;
break ;
case (char) 96:
sKey.Append ("/%DCN096%/") ;
break ;
case (char) 124:
sKey.Append ("/%DCN124%/") ;
break ;
case (char) 126:
sKey.Append ("/%DCN126%/") ;
break ;
default:
sKey.Append (key[i]) ;
break ;
} ;
}
return sKey.ToString () ;
}