示例#1
0
 public void GetParameters()
 {
     KaTb.Text      = K.ToString() + ";";
     tetanaTb.Text  = Tn.ToString() + ";";
     tetasaTb.Text  = Ts.ToString() + ";";
     tetacaTb.Text  = Tc.ToString() + ";";
     NcaTb.Text     = Nc.ToString() + ";";
     LaTb.Text      = L.ToString() + ";";
     lowerkaTb.Text = k.ToString() + ";";
     IaTb.Text      = i.ToString() + ";";
 }
示例#2
0
        public byte[] Encode()
        {
            Encoding encoding;

            if (!string.IsNullOrEmpty(Charset))
            {
                encoding = Encoding.GetEncoding(Charset);
            }
            else
            {
                encoding = Encoding.UTF8;
            }

            using (var memory = new MemoryStream()) {
                byte[] buf;

                buf = Encoding.ASCII.GetBytes("username=\"");
                memory.Write(buf, 0, buf.Length);
                buf = encoding.GetBytes(UserName);
                memory.Write(buf, 0, buf.Length);

                buf = Encoding.ASCII.GetBytes("\",realm=\"");
                memory.Write(buf, 0, buf.Length);
                buf = encoding.GetBytes(Realm);
                memory.Write(buf, 0, buf.Length);

                buf = Encoding.ASCII.GetBytes("\",nonce=\"");
                memory.Write(buf, 0, buf.Length);
                buf = encoding.GetBytes(Nonce);
                memory.Write(buf, 0, buf.Length);

                buf = Encoding.ASCII.GetBytes("\",cnonce=\"");
                memory.Write(buf, 0, buf.Length);
                buf = encoding.GetBytes(CNonce);
                memory.Write(buf, 0, buf.Length);

                buf = Encoding.ASCII.GetBytes("\",nc=");
                memory.Write(buf, 0, buf.Length);
                buf = Encoding.ASCII.GetBytes(Nc.ToString("X8"));
                memory.Write(buf, 0, buf.Length);

                buf = Encoding.ASCII.GetBytes(",qop=\"");
                memory.Write(buf, 0, buf.Length);
                buf = Encoding.ASCII.GetBytes(Qop);
                memory.Write(buf, 0, buf.Length);

                buf = Encoding.ASCII.GetBytes("\",digest-uri=\"");
                memory.Write(buf, 0, buf.Length);
                buf = Encoding.ASCII.GetBytes(DigestUri.ToString());
                memory.Write(buf, 0, buf.Length);

                buf = Encoding.ASCII.GetBytes("\",response=\"");
                memory.Write(buf, 0, buf.Length);
                buf = Encoding.ASCII.GetBytes(Response);
                memory.Write(buf, 0, buf.Length);
                buf = new byte[] { (byte)'"' };
                memory.Write(buf, 0, buf.Length);

                if (MaxBuf > 0)
                {
                    buf = Encoding.ASCII.GetBytes(",maxbuf=");
                    memory.Write(buf, 0, buf.Length);
                    buf = Encoding.ASCII.GetBytes(MaxBuf.ToString());
                    memory.Write(buf, 0, buf.Length);
                }

                if (!string.IsNullOrEmpty(Charset))
                {
                    buf = Encoding.ASCII.GetBytes(",charset=\"");
                    memory.Write(buf, 0, buf.Length);
                    buf = Encoding.ASCII.GetBytes(Charset);
                    memory.Write(buf, 0, buf.Length);
                    buf = new byte[] { (byte)'"' };
                    memory.Write(buf, 0, buf.Length);
                }

                if (!string.IsNullOrEmpty(Algorithm))
                {
                    buf = Encoding.ASCII.GetBytes(",algorithm=\"");
                    memory.Write(buf, 0, buf.Length);
                    buf = Encoding.ASCII.GetBytes(Algorithm);
                    memory.Write(buf, 0, buf.Length);
                    buf = new byte[] { (byte)'"' };
                    memory.Write(buf, 0, buf.Length);
                }

                if (!string.IsNullOrEmpty(Cipher))
                {
                    buf = Encoding.ASCII.GetBytes(",cipher=\"");
                    memory.Write(buf, 0, buf.Length);
                    buf = Encoding.ASCII.GetBytes(Cipher);
                    memory.Write(buf, 0, buf.Length);
                    buf = new byte[] { (byte)'"' };
                    memory.Write(buf, 0, buf.Length);
                }

                if (!string.IsNullOrEmpty(AuthZid))
                {
                    buf = Encoding.ASCII.GetBytes(",authzid=\"");
                    memory.Write(buf, 0, buf.Length);
                    buf = Encoding.ASCII.GetBytes(AuthZid);
                    memory.Write(buf, 0, buf.Length);
                    buf = new byte[] { (byte)'"' };
                    memory.Write(buf, 0, buf.Length);
                }

                return(memory.ToArray());
            }
        }