Example #1
0
            public byte[] ToBytes()
            {
                MemoryStream ms = new MemoryStream();
                BinaryWriter bw = new BinaryWriter(ms);

                bw.Write(ID);
                bw.Write(Response);
                bw.Write((byte)PacketType);
                bw.Write(CurrentUser.KeyIndex);
                bw.Write(Port);
                MemoryStream ems = new MemoryStream();
                BinaryWriter ebw = new BinaryWriter(ems); //2015.04.03.

                ebw.Write(EUserID);
                ebw.Write(EData.ToBytes());
                ebw.Flush();
                if (CurrentUser.Keys[KeyIndex] != null)
                {
                    bw.Write(Storage.Encrypt(ems.ToArray(), CurrentUser.Keys[KeyIndex]));
                }
                else
                {
                    bw.Write(Storage.Encrypt(ems.ToArray(), "ihavenokeys"));
                }
                bw.Flush();
                return(ms.ToArray());
            }