![]() |
|
|
#6 |
|
Архивный участник
Join Date: Nov 2004
Posts: 1,405
|
public static byte[] L2EncryptPwd(string pwd)
{ char[] key = new char[16]; char[] dstStr = new char[16]; string encryptStr = ""; int one; int two; int three; int four; if(pwd.Length > 16) { return null; } Array.Copy(pwd.ToCharArray(), key, pwd.ToCharArray().Length); Array.Copy(pwd.ToCharArray(), dstStr, pwd.ToCharArray().Length); one = (int)key[0] + ((int)key[1] << 8) + ((int)key[2] << 16) + ((int)key[3] << 24); one = one * 213119 + 2529077; two = (int)key[4] + ((int)key[5] << 8) + ((int)key[6] << 16) + ((int)key[7] << 24); two = two * 213247 + 2529089; three = (int)key[8] + ((int)key[9] << 8) + ((int)key[10] << 16) + ((int)key[11] << 24); three = three * 213203 + 2529589; four = (int)key[12] + ((int)key[13] << 8) + ((int)key[14] << 16) + ((int)key[15] << 24); four = four * 213821 + 2529997; key[0] = (char)(one); key[1] = (char)(one >> 8); key[2] = (char)(one >> 16); key[3] = (char)(one >> 24); key[4] = (char)(two >> 0); key[5] = (char)(two >> 8); key[6] = (char)(two >> 16); key[7] = (char)(two >> 24); key[8] = (char)(three >> 0); key[9] = (char)(three >> 8); key[10] = (char)(three >> 16); key[11] = (char)(three >> 24); key[12] = (char)(four >> 0); key[13] = (char)(four >> 8); key[14] = (char)(four >> 16); key[15] = (char)(four >> 24); dstStr[0] = (char)((byte)dstStr[0] ^ (byte)key[0]); // if((byte)dstStr[0] == 0) // { // encryptStr += "66"; // } // else // { // encryptStr += ((byte)dstStr[0]).ToString("X2"); // } for(int i=1; i<16; i++) { dstStr = (char)((byte)dstStr ^ (byte)dstStr[i-1] ^ (byte)key[i & 0xF]); // if((byte)dstStr == 0) // { // encryptStr += "66"; // } // else // { // encryptStr += ((byte)dstStr).ToString("X2"); // } } byte[] retVal = new byte[16]; for(int i=1; i<16; i++) { if((byte)dstStr == 0) { retVal = 0x66; } else { retVal = (byte)dstStr; } } /* for(int i=0; i<16; i++) { if((byte)dstStr == 0) { dstStr = (char)0x66; } encryptStr += ((byte)dstStr).ToString("X2"); } */ return retVal; } |
|
|
| Thread Tools | Search this Thread |
| Display Modes | |
|
|