right key calculation?

Technical discussion about the NMDC and <a href="http://dcpp.net/ADC.html">ADC</A> protocol. The NMDC protocol is documented in the <a href="http://dcpp.net/wiki/">Wiki</a>, so feel free to refer to it.

Moderator: Moderators

Locked
Freak.2k
Posts: 8
Joined: 2004-10-04 14:00

right key calculation?

Post by Freak.2k » 2004-10-05 14:45

Hello,

can someone check, if my key is calculated right?
Lock: testlock
Key: 97 11 61 70 81 30 C0 80 (Hex values)

after I send the key and validatenick to the hub, I get disconnected....

ivulfusbar
Posts: 506
Joined: 2003-01-03 07:33

Post by ivulfusbar » 2004-10-06 03:21

Visit http://dcplusplus.sourceforge.net/wiki/index.php/LockToKey where we have several working lock to key programs. You should be able to check with any of those code-examples.

we-love-those-who-help-themself-ly'ers
Everyone is supposed to download from the hubs, - I don´t know why, but I never do anymore.

Freak.2k
Posts: 8
Joined: 2004-10-04 14:00

Post by Freak.2k » 2004-10-06 07:05

I think my key is correct.
But after I send "$Key <key>|$ValidateNick <Nick>|" I get disconnected
the dc hub says "Dropping unknown connection (null)"

what can this be?

ivulfusbar
Posts: 506
Joined: 2003-01-03 07:33

Post by ivulfusbar » 2004-10-06 07:49

1) Don't think. Make sure the key its correct.

2) Compare it with dc++ loggin in.
Everyone is supposed to download from the hubs, - I don´t know why, but I never do anymore.

Freak.2k
Posts: 8
Joined: 2004-10-04 14:00

Post by Freak.2k » 2004-10-06 16:24

OK...my key is wrong :(
But i tried everything. I can't find any mistake in my code.
I tried other code snippets from this forum, but nothing works.
Does anyone have a 100% working c# code to generate the key?

thx

joakim_tosteberg
Forum Moderator
Posts: 587
Joined: 2003-05-07 02:38
Location: Sweden, Linkoping

Post by joakim_tosteberg » 2004-10-06 23:03

Post your code and someone mught be able to find the problem with it .

TheParanoidOne
Forum Moderator
Posts: 1420
Joined: 2003-04-22 14:37

Post by TheParanoidOne » 2004-10-07 00:20

Preferably a link to the code, rather than the code itself. The word wrapping here will maake the code unreadable.
The world is coming to an end. Please log off.

DC++ Guide | Words

Freak.2k
Posts: 8
Joined: 2004-10-04 14:00

Post by Freak.2k » 2004-10-07 06:00


joakim_tosteberg
Forum Moderator
Posts: 587
Joined: 2003-05-07 02:38
Location: Sweden, Linkoping

Post by joakim_tosteberg » 2004-10-07 11:07

I think

Code: Select all

return (byte)(((KeyByte << 4) & 0xF0) | ((KeyByte >> 4) & 0x0F));

should be replaced with

Code: Select all

return (byte)(((KeyByte << 4) & 240) | ((KeyByte >> 4) 15));
(This is the values the example is telling to use and the values I use in c++)

Also, I'm not sure that your approatch to load the KeyBytes array works properly but I'm not sure (that approach caused problems for me in c++ but I'm not sure how C# handes it).
Anyway I would suggest to use

Code: Select all

 KeyBytes += (byte)(LockBytes[i] ^ LockBytes[i - 1]);
and eighter initalize the string with " " and then replace that element in the next stage using wathevere function C# has for that or just insert a new character in fron of the string (don't initialize the string to anything if you use this approach). I'm not sure what C# has for function for this eighter but in C++ the first is .replace and the second .insert

PseudonympH
Forum Moderator
Posts: 366
Joined: 2004-03-06 02:46

Post by PseudonympH » 2004-10-10 22:10

F0 hex = 240 decimal, and 0F hex = 15 decimal. At least his numbers are correct....

Freak.2k
Posts: 8
Joined: 2004-10-04 14:00

Post by Freak.2k » 2004-10-11 03:03

it works now.
It was a conversation problem.
When I converted the key-string to a byte array (for sending over the socket), some characters were converted wrong by the .Net Runtime!
I wrote my own conversation method...now it works fine

Locked