Exemplo n.º 1
0
 public void Init(int seed)
 {
     byte[] s = new byte[4];
     md.Begin();
     this.sumResidue = 0;
     CheckSum.SIVAL(ref s, 0, (UInt32)seed);
     Update(s, 0, 4);
 }
Exemplo n.º 2
0
        /// <summary>
        /// Writes Int64 value to out buffer
        /// </summary>
        /// <param name="x"></param>
        public void WriteLongInt(Int64 x)
        {
            byte[] data = new byte[8];

            if (x <= 0x7FFFFFFF)
            {
                writeInt((int)x);
                return;
            }

            writeUInt(0xFFFFFFFF);
            CheckSum.SIVAL(ref data, 0, (UInt32)(x & 0xFFFFFFFF));
            CheckSum.SIVAL(ref data, 4, (UInt32)((x >> 32) & 0xFFFFFFFF));

            Write(data, 0, 8);
        }
Exemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="code"></param>
        /// <param name="buffer"></param>
        /// <param name="count"></param>
        public void MultiplexWrite(MsgCode code, byte[] buffer, int count)
        {
            byte[] localBuffer = new byte[4096];
            int    n           = count;

            CheckSum.SIVAL(ref localBuffer, 0, (UInt32)(((MPLEX_BASE + (int)code) << 24) + count));

            if (n > localBuffer.Length - 4)
            {
                n = localBuffer.Length - 4;
            }

            Util.MemoryCopy(localBuffer, 4, buffer, 0, n);
            socketOut.Write(localBuffer, 0, n + 4);

            count -= n;
            if (count > 0)
            {
                socketOut.Write(buffer, n, count);
            }
        }
Exemplo n.º 4
0
        public void MplexWrite(MsgCode code, byte[] buf, int len)
        {
            byte[] buffer = new byte[4096];
            int    n      = len;

            CheckSum.SIVAL(ref buffer, 0, (UInt32)(((MPLEX_BASE + (int)code) << 24) + len));

            if (n > buffer.Length - 4)
            {
                n = buffer.Length - 4;
            }

            Util.MemCpy(buffer, 4, buf, 0, n);
            sockOut.Write(buffer, 0, n + 4);

            len -= n;
            if (len > 0)
            {
                sockOut.Write(buf, n, len);
            }
        }
Exemplo n.º 5
0
        public static string gen_challenge(string addr, Options opt)
        {
            string challenge = "";

            byte[]   input = new byte[32];
            DateTime tv    = DateTime.Now;

            for (int i = 0; i < addr.Length; i++)
            {
                input[i] = Convert.ToByte(addr[i]);
            }

            CheckSum.SIVAL(ref input, 16, (UInt32)tv.Second);
            CheckSum.SIVAL(ref input, 20, (UInt32)tv.Hour);
            CheckSum.SIVAL(ref input, 24, (UInt32)tv.Day);

            Sum sum = new Sum(opt);

            sum.Init(0);
            sum.Update(input, 0, input.Length);
            challenge = Encoding.ASCII.GetString(sum.End());
            return(challenge);
        }