All pastes #960321 Raw Edit

Someone

public text v1 · immutable
#960321 ·published 2008-03-28 00:37 UTC
rendered paste body
    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);
        }
    }