Advertisement
Guest User

Untitled

a guest
Aug 16th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.75 KB | None | 0 0
  1. using System;
  2. using System.IO;
  3. using System.Text;
  4. using COServer.Network.Cryptography;
  5. using COServer.Cryptography;
  6.  
  7. namespace COServer.Network.AuthPackets
  8. {
  9. public class Authentication : Interfaces.IPacket
  10. {
  11. public string Username;
  12. public string Password;
  13. public string Server;
  14.  
  15.  
  16. public Authentication()
  17. {
  18. }
  19. public void Deserialize(byte[] buffer)
  20. {
  21. if (buffer.Length == 312)
  22. {
  23. ushort length = BitConverter.ToUInt16(buffer, 0);
  24.  
  25. if (length == 312)
  26. {
  27.  
  28. ushort type = BitConverter.ToUInt16(buffer, 2);
  29. byte[] temp = new byte[16];
  30. if (type == 1542)
  31. {
  32. MemoryStream MS = new MemoryStream(buffer);
  33. BinaryReader BR = new BinaryReader(MS);
  34.  
  35. BR.ReadUInt16();
  36. BR.ReadUInt16();
  37. Username = Encoding.Default.GetString(BR.ReadBytes(32));
  38. Username = Username.Replace("\0", "");
  39. BR.ReadBytes(36);
  40. var PasswordArray = BR.ReadBytes(32);
  41. LoaderEncryption.Decrypt(PasswordArray, 32);
  42. Password = Encoding.Default.GetString(PasswordArray);
  43. Password = Password.Replace("\0", "");
  44. BR.ReadBytes(32);
  45. Server = Encoding.Default.GetString(BR.ReadBytes(32));
  46. Server = Server.Replace("\0", "");
  47. BR.Close();
  48. MS.Close();
  49. }
  50. }
  51. }
  52. }
  53. /*public void Deserialize(byte[] buffer)
  54. {
  55. if (buffer.Length == 312)
  56. {
  57. ushort length = BitConverter.ToUInt16(buffer, 0);
  58.  
  59. if (length == 312)
  60. {
  61.  
  62. ushort type = BitConverter.ToUInt16(buffer, 2);
  63. byte[] temp = new byte[16];
  64. if (type == 1542)
  65. {
  66. MemoryStream MS = new MemoryStream(buffer);
  67. BinaryReader BR = new BinaryReader(MS);
  68. BR.ReadUInt16();
  69. BR.ReadUInt16();
  70. Username = Encoding.Default.GetString(BR.ReadBytes(32));
  71. Username = Username.Replace("\0", "");
  72. BR.ReadBytes(36);
  73. Password = Encoding.Default.GetString(BR.ReadBytes(32));
  74. Password = Password.Replace("\0", "");
  75. BR.ReadBytes(32);
  76. Server = Encoding.Default.GetString(BR.ReadBytes(32));
  77. Server = Server.Replace("\0", "");
  78. BR.Close();
  79. MS.Close();
  80. }
  81. }
  82. }
  83. }*/
  84. /*public void Deserialize(byte[] buffer)
  85. {
  86. if (buffer.Length == 312)
  87. {
  88. ushort length = BitConverter.ToUInt16(buffer, 0);
  89.  
  90. if (length == 312)
  91. {
  92.  
  93. ushort type = BitConverter.ToUInt16(buffer, 2);
  94. byte[] temp = new byte[16];
  95. if (type == 1542)
  96. {
  97. MemoryStream MS = new MemoryStream(buffer);
  98. BinaryReader BR = new BinaryReader(MS);
  99. BR.ReadUInt16();
  100. BR.ReadUInt16();
  101. Username = Encoding.Default.GetString(BR.ReadBytes(32));
  102. Username = Username.Replace("\0", "");
  103. BR.ReadBytes(37);
  104. byte[] PasswordArray = BR.ReadBytes(32);
  105. Password = Encoding.Default.GetString(PasswordArray);
  106. LoaderEncryption.Decrypt(PasswordArray);
  107. Password = Encoding.Default.GetString(PasswordArray);
  108. Password = Password.Replace("\0", "");
  109. BR.ReadBytes(31);
  110. Server = Encoding.Default.GetString(BR.ReadBytes(16));
  111. Server = Server.Replace("\0", "");
  112. BR.Close();
  113. MS.Close();
  114. }
  115. }
  116. }
  117. }*/
  118.  
  119. public byte[] ToArray()
  120. {
  121. throw new NotImplementedException();
  122. }
  123. public void Send(Client.GameState client)
  124. {
  125. throw new NotImplementedException();
  126. }
  127. }
  128. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement