class SaltAuthentication { public void SendPacket(ClientBase client, out string ServerSalt) { byte[] Packet = new byte[] { 0xDF, 0xDF, 0x00, 0x01, 0x00, 0x01, 0x00, 0x34, // Total Length of Packet 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x2B, 0x3F, 0x00, 0x00, 0x00, 0x24, // Packet Type (SaltAuthentication) 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Server Salt (32 Bytes) 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; byte[] Salt = new byte[0x20]; Random rand = new Random(); rand.NextBytes(Salt); ServerSalt = string.Empty; for (int i = 0; i < 32; i++) { if (Salt[i] == 0) // 0x00 Breaks Things Salt[i] = 42; // So we change it to something nicer Packet[20 + i] = Salt[i]; ServerSalt += String.Format("{0:x2}", Salt[i]); } client.Send(Packet); } }