| | |
| | | /** 字节流的加解密 */ |
| | | public class GameNetEncode |
| | | { |
| | | static int[] gSendKeyDict = new int[1024] //发送加密用密钥 |
| | | { |
| | | int[] gSendKeyDict = new int[1024] //发送加密用密钥 |
| | | { |
| | | 0x3bc46229, 0x71463c13, 0x4df97c63, 0x20a6b7b6, 0x5cb0c110, 0x780d5397, 0x161f22f9, 0x71f1eda0, |
| | | 0x4c4797a4, 0x7b3d7177, 0x2679595a, 0x54c92286, 0x2af45923, 0x2e5cd5f4, 0x5bc860c7, 0x14929ca9, |
| | | 0x1fef64cf, 0x30a25d4c, 0x5daf8680, 0x4553de47, 0x787d45e5, 0x5631bfc0, 0x6de263c5, 0x3493e5a1, |
| | |
| | | 0x3749b51a, 0x2528dcc6, 0x15d6a9e0, 0x5350cd24, 0x1c842639, 0x649b2f61, 0x7c8cd7ed, 0x7f088866, |
| | | 0x7fbaf784, 0x3cf212da, 0x114b4a47, 0x7680c924, 0x3e68543c, 0x59dd5f6e, 0x1c023a2c, 0x18efad9f, |
| | | 0x7e33d39e, 0x6ba0095e, 0x35f16cdd, 0x70491015, 0x1f69b8ee, 0x506460eb, 0x594d739a, 0x1478c6c8 |
| | | }; |
| | | }; |
| | | |
| | | static byte[] gSendKeyBytes;//加工后的加密钥 |
| | | static int m_KeyEncodeIndex = 250; |
| | | public static int KeyEncodeIndex |
| | | { |
| | | byte[] gSendKeyBytes;//加工后的加密钥 |
| | | int m_KeyEncodeIndex = 250; |
| | | public int KeyEncodeIndex { |
| | | get { return m_KeyEncodeIndex; } |
| | | set { m_KeyEncodeIndex = value; } |
| | | } |
| | | |
| | | /** 解密用字串 */ |
| | | static byte[] gKeyBytes = new byte[] {184,187,199,191,32,195,241,214,247,32,206,196,195,247,32,186,205,208,179,32,215,212,211,201,32,198,189,181,200,32,185,171,213,253,32,183,168,214,206,32,176,174,185,250,32,190,180,210,181,32,179,207,208,197,32,211,209,201,198 |
| | | }; |
| | | byte[] gKeyBytes = new byte[] { 184, 187, 199, 191, 32, 195, 241, 214, 247, 32, 206, 196, 195, 247, 32, 186, 205, 208, 179, 32, 215, 212, 211, 201, 32, 198, 189, 181, 200, 32, 185, 171, 213, 253, 32, 183, 168, 214, 206, 32, 176, 174, 185, 250, 32, 190, 180, 210, 181, 32, 179, 207, 208, 197, 32, 211, 209, 201, 198 }; |
| | | |
| | | /// <summary> |
| | | /// 加密 |
| | | /// </summary> |
| | | /// <param name="vBuffer"></param> |
| | | /// <returns></returns> |
| | | public static byte[] BaseXorAdd(byte[] vBuffer) |
| | | public byte[] BaseXorAdd(byte[] vBuffer) |
| | | { |
| | | ConfigEncodeKey(); |
| | | return BaseXorAdd(vBuffer, gSendKeyBytes); |
| | |
| | | /// <param name="vBuffer"></param> |
| | | /// <param name="vPassword"></param> |
| | | /// <returns></returns> |
| | | static byte[] BaseXorAdd(byte[] vBuffer, byte[] vPassword) |
| | | byte[] BaseXorAdd(byte[] vBuffer, byte[] vPassword) |
| | | { |
| | | int i; |
| | | int l = vBuffer.Length; |
| | |
| | | /// </summary> |
| | | /// <param name="vBuffer"></param> |
| | | /// <returns></returns> |
| | | public static byte[] BaseXorSub(byte[] vBuffer) |
| | | public byte[] BaseXorSub(byte[] vBuffer) |
| | | { |
| | | return BaseXorSub(vBuffer, gKeyBytes); |
| | | } |
| | |
| | | /// <param name="vBuffer"></param> |
| | | /// <param name="vPassword"></param> |
| | | /// <returns></returns> |
| | | static byte[] BaseXorSub(byte[] vBuffer, byte[] vPassword) |
| | | byte[] BaseXorSub(byte[] vBuffer, byte[] vPassword) |
| | | { |
| | | int i; |
| | | byte ucByte = 0; |
| | |
| | | /// <summary> |
| | | /// 配置加密密钥 |
| | | /// </summary> |
| | | static void ConfigEncodeKey() |
| | | void ConfigEncodeKey() |
| | | { |
| | | int vIndex = KeyEncodeIndex % gSendKeyDict.Length; |
| | | gSendKeyBytes = BitConverter.GetBytes((int)(gSendKeyDict[vIndex] ^ Snxxz.UI.LoginModel.DwVersionNo)); |
| | | KeyEncodeIndex++; |
| | | } |
| | | |
| | | public static void ResetEncodeIndex() |
| | | { |
| | | KeyEncodeIndex = 250; |
| | | } |
| | | |
| | | } |