// Token: 0x06000177 RID: 375 RVA: 0x0000D8EC File Offset: 0x0000BAEC public void Load(byte[] bytes) { this.index = BitConverter.ToUInt16(new byte[] { bytes[0], bytes[1] }, 0); this.length = BitConverter.ToUInt16(new byte[] { bytes[2], bytes[3] }, 0); this.crc2 = bytes[(int)((ushort)Frame.HeaderSize + this.length - 1)]; this.crc2ok = (this.crc2 == Frame.GetCRC(bytes, 0, (int)((ushort)Frame.HeaderSize + this.length - 1))); if (this.index != 65535) { if (Frame.Encrypt) { this.tcpVector[0] = bytes[0]; this.tcpVector[1] = bytes[1]; VMPC.Encode(bytes, 4, (int)((ushort)Frame.HeaderSize + this.length - 1), this.tcpKey, this.tcpVector, 16); } this.type = bytes[4]; this.data = new byte[(int)this.length]; for (int i = 0; i < (int)this.length; i++) { this.data[i] = bytes[5 + i]; } } else { if (Frame.Encrypt) { VMPC.Encode(bytes, 13, (int)((ushort)Frame.HeaderSize + this.length - 1), this.tcpKey, this.tcpVector, 16); } this.type = bytes[4]; this.data = new byte[(int)(this.length - 8)]; for (int j = 0; j < (int)(this.length - 8); j++) { this.data[j] = bytes[13 + j]; } } this.crc1 = bytes[(int)((ushort)Frame.HeaderSize + this.length - 2)]; this.crc1ok = (this.crc1 == Frame.GetCRC(bytes, 4, (int)((ushort)Frame.HeaderSize + this.length - 2))); }
public static string EncodeString(string str, string key, string vec) { if (str != null && !string.IsNullOrEmpty(str)) { byte[] bytes = Encoding.UTF8.GetBytes(str); char[] array = key.ToCharArray(); byte[] array2 = new byte[array.Length]; for (int i = 0; i < array.Length; i++) { array2[i] = (byte)array[i]; } char[] array3 = vec.ToCharArray(); byte[] array4 = new byte[array3.Length]; for (int j = 0; j < array3.Length; j++) { array4[j] = (byte)array3[j]; } VMPC.Encode(bytes, 0, bytes.Length, array2, array4, array4.Length); return(Convert.ToBase64String(bytes)); } return(str); }
// Token: 0x06000178 RID: 376 RVA: 0x0000DA98 File Offset: 0x0000BC98 public byte[] ToBytes() { this.length = ((this.data != null) ? ((ushort)this.data.Length) : 0); byte[] array = new byte[(int)((ushort)Frame.HeaderSize + this.length)]; array[0] = BitConverter.GetBytes(this.index)[0]; array[1] = BitConverter.GetBytes(this.index)[1]; array[2] = BitConverter.GetBytes(this.length)[0]; array[3] = BitConverter.GetBytes(this.length)[1]; array[4] = this.type; for (int i = 0; i < (int)this.length; i++) { array[5 + i] = this.data[i]; } array[(int)((ushort)Frame.HeaderSize + this.length - 2)] = Frame.GetCRC(array, 4, array.Length - 2); if (Frame.Encrypt) { this.tcpVector[0] = array[0]; this.tcpVector[1] = array[1]; VMPC.Encode(array, 4, (int)((ushort)Frame.HeaderSize + this.length - 1), this.tcpKey, this.tcpVector, 16); } array[(int)((ushort)Frame.HeaderSize + this.length - 1)] = Frame.GetCRC(array, 0, array.Length - 1); return(array); }
public static string DecodeString(string str, string key, string vec) { if (str != null && !string.IsNullOrEmpty(str)) { byte[] array = Convert.FromBase64String(str); char[] array2 = key.ToCharArray(); byte[] array3 = new byte[array2.Length]; for (int i = 0; i < array2.Length; i++) { array3[i] = (byte)array2[i]; } char[] array4 = vec.ToCharArray(); byte[] array5 = new byte[array4.Length]; for (int j = 0; j < array4.Length; j++) { array5[j] = (byte)array4[j]; } VMPC.Encode(array, 0, array.Length, array3, array5, array5.Length); return(Encoding.UTF8.GetString(array)); } return(str); }