public static string Decode(string key, byte[] bt) { byte[] dbt = new byte[bt.Length - 3]; Buffer.BlockCopy(bt, 3, dbt, 0, dbt.Length); string ret = Encrypter_AES.DecryptToString(dbt, key); return(ret); }
public static byte[] Encode(string key, byte[] bt, ushort protocolVersion, bool isSpecifiedKey) { byte[] body = Encrypter_AES.EncryptBinary(bt, key); //AES密文 byte[] tempdata = BitConverter.GetBytes(isSpecifiedKey); //是否使用服务器指定密码 body = body.Prepend(tempdata); tempdata = BitConverter.GetBytes(protocolVersion); //协议版本号 body = body.Prepend(tempdata); tempdata = BitConverter.GetBytes((UInt32)(body.Length)); //包体长度 body = body.Prepend(tempdata); return(body); }