Всем доброго времени суток!
Цитата | How to calculate the key from the lock: We begin with creating a buffer exactly as big as the lock-string. Now for each character with index i in the lock-string (except from the first one where i = 0) we'll calculate the key at that position from the character i and i-1. Then we calculate the first key character from the first lock character and the two last. When this is done, we nibble-swap the entire key. Now we have a key that is almost ready to be sent to the server. We just have to replace a few characters with a meta-character. An example in c++ (we have a lock lock and we send using send()):
Код | // get size from lock-string int len = strlen(lock); // create buffer for key char *key = new char[len]; // create the key-data for (i = 1; i < len; i++) key[i] = lock[i] ^ lock[i-1]; key[0] = lock[0] ^ lock[len-1] ^ lock[len-2] ^ 5; // nibble-swap the key for (i = 0; i < len; i++) key[i] = ((key[i]<<4) & 240) | ((key[i]>>4) & 15); escapeDCN(key); string s = "$Key "; s += key; send(s); delete[] key;
|
The escapeDCN is a function that escapes the characters 0, 5, 36, 96, 124, and 126 to /%DCN000%/, /%DCN005%/, /%DCN036%/, /%DCN096%/, /%DCN124%/, and /%DCN126%/ respectively.
|
Это цитата из доки по опсианию дц протокола. Есть проблема: Нужно код на C перевести в рабочий код на Perl'e, но С я вообще не знаю  Помогите, пожалуйста!
Всем зараннее спасибо!
Gh0sT |