Location:
Search - mySQLDbTables
Search list
Description: using System;
using System.Collections.Generic;
using System.Text;
namespace NewestCOServer
{
public class Cryption
{
class CryptCounter
{
UInt16 m_Counter = 0;
public byte Key2
{
get { return (byte)(m_Counter >> 8); }
}
public byte Key1
{
get { return (byte)(m_Counter & 0xFF); }
}
public void Increment()
{
m_Counter++;
}
}
private CryptCounter _decryptCounter;
private CryptCounter _encryptCounter;
private byte[] _cryptKey1;
private byte[] _cryptKey2;
private byte[] _cryptKey3;
private byte[] _cryptKey4;
private bool Decrypt2 = false;
public Cryption()
{
_decryptCounter = new CryptCounter();
_encryptCounter = new CryptCounter();
_cryptKey1 = new byte[0x100];
_cryptKey2 = new byte[0x100];
byte i_key1 = 0x9D;
byte i_key2 = 0x62;
for (int i = 0; i 4 | buffer[i] < 4 | buffer[i] < 4 | buffer[i] << 4);
buffer[i] ^= (byte)(_cryptKey4[_decryptCounter.Key2] ^ _cryptKey3[_decryptCounter.Key1]);
_decryptCounter.Increment();
}
}
}
public void GenerateKeys(UInt32 CryptoKey, UInt32 AccountID)
{
UInt32 tmpkey1 = 0, tmpkey2 = 0;
tmpkey1 = ((CryptoKey + AccountID) ^ (0x4321)) ^ CryptoKey;
tmpkey2 = tmpkey1 * tmpkey1;
_cryptKey3 = new byte[256];
_cryptKey4 = new byte[256];
for (int i = 0; i < 256; i++)
{
int right = ((3 - (i % 4)) * 8);
int left = ((i % 4)) * 8 + right;
_cryptKey3[i] = (byte)(_cryptKey1[i] ^ tmpkey1 left);
_cryptKey4[i] = (byte)(_cryptKey2[i] ^ tmpkey2 left);
}
Decrypt2 = true;
}
public void GenerateKeys2(byte[] InKey1, byte[] InKey2)
{
byte[] addKey1 = new byte[4];
byte[] addKey2 = new byte[4];
byte[] addResult = new byte[4];
//addKey1.i = 0;
//addKey2.i = 0;
byte[] tempKey = new byte[4];
long LMULer;
// InKey1[0] = 0x20;
// InKey1[1] = 0x5c;
// InKey1[2] = 0x48;
// InKey1[3] = 0xf4;
// InKey2[0] = 0x00;
// InKey2[1] = 0x44;
// InKey2[2] = 0xa6;
// InKey2[3] = 0x2e;
//if (Key3) delete [] Key3;
//if (Key4) delete [] Key4;
_cryptKey3 = new byte[256];
_cryptKey4 = new byte[256];
for (int x = 0; x < 4; x++)
{
addKey1[x] = InKey1[3 - x];
addKey2[x] = InKey2[3 - x];
}
//cout << "Key1: " << addKey1.i << endl;
//cout << "Key2: " << addKey2.i << endl;
uint Adder1;
uint Adder2;
uint Adder3;
Adder1 = (uint)((addKey1[3] << 24) | (addKey1[2] << 16) | (addKey1[1] << 8) | (addKey1[0]));
Adder2 = (uint)((addKey2[3] << 24) | (addKey2[2] << 16) | (addKey2[1] 8) & 0xff);
addResult[2] = (byte)((Adder3 >> 16) & 0xff);
addResult[3] = (byte)((Adder3 >> 24) & 0xff);
for (int b = 3; b >= 0; b--)
{
// printf("%.2x ", addResult.c[b]);
tempKey[3 - b] = addResult[b];
}
tempKey[2] = (byte)(tempKey[2] ^ (byte)0x43);
tempKey[3] = (byte)(tempKey[3] ^ (byte)0x21);
for (int b = 0; b < 4; b++)
{
tempKey[b] = (byte)(tempKey[b] ^ InKey1[b]);
}
//Build the 3rd Key
for (int b = 0; b < 256; b++)
{
_cryptKey3[b] = (byte)(tempKey[3 - (b % 4)] ^ _cryptKey1[b]);
}
for (int x = 0; x < 4; x++)
{
addResult[x] = tempKey[3 - x];
}
Adder3 = (uint)((addResult[3] << 24) | (addResult[2] << 16) | (addResult[1] << 8) | (addResult[0]));
LMULer = Adder3 * Adder3;
LMULer = LMULer 32;
Adder3 = Convert.ToUInt32(LMULer & 0xffffffff);
addResult[0] = (byte)(Adder3 & 0xff);
addResult[1] = (byte)((Adder3 >> 8) & 0xff);
addResult[2] = (byte)((Adder3 >> 16) & 0xff);
addResult[3] = (byte)((Adder3 >> 24) & 0xff);
for (int b = 3; b >= 0; b--)
{
tempKey[3 - b] = addResult[b];
}
//Build the 4th Key
for (int b = 0; b < 256; b++)
{
_cryptKey4[b] = Convert.ToByte(tempKey[3 - (b % 4)] ^ _cryptKey2[b]);
}
Decrypt2 = true;
//cout << "Int representation: " << charadd.i << endl;
}
}
}
Platform: |
Size: 3638778 |
Author: andesion@vip.qq.com |
Hits:
Description: Mysql控件安装程序(CBC),帮你快捷访问MYSQL.-Mysql control setup program (CBC), help you quickly visit MYSQL.
Platform: |
Size: 1038336 |
Author: zzg |
Hits:
Description: fpga 控制dds 程序。希望对各位有用-dds FPGA control procedures. Members wish to be useful
Platform: |
Size: 88064 |
Author: martin |
Hits:
Description: 此源代码是基于Verilog语言的七人投票表决器 、2 个 8 位数相乘 、8 位二进制数的乘法 、同一循环的不同实现方式、使用了`include 语句的 16 位加法器 、条件编译、加法计数器中的进程、任务、测试、函数、用函数和 case语句描述的编码器、阶乘运算函数、测试程序 、顺序执行、并行执行,特别是七人投票表决器,这是我目前发现的最优的用硬件描述的源代码。-The Verilog language source code is based on the seven-vote, and 2 8-digit multiplication, 8-bit binary number multiplication, the same cycle of different implementations, using the `include statements of the 16-bit adder, conditional compilation, addition counter processes, tasks, test, function, function and case statement with the description of the encoder, computing the factorial function, test procedures, the order of execution, parallel execution, especially the seven-vote, this is the most I have found so far excellent description of the source code with the hardware.
Platform: |
Size: 2048 |
Author: 王柔毅 |
Hits:
Description: 加法计数器 简单的加法计数器 专用于学生学习理解-Counter counter simple addition addition dedicated to understanding student learning
Platform: |
Size: 1024 |
Author: 林凯 |
Hits: