private static void MakePrincipleHeader(HttpRequestMessage reqMsg, string strUri)
        {
            Guid guid = Guid.NewGuid();

            strUri = InternalHelper.GetEffectiveUri(strUri);
            string strToEncrypt  = Md5.MD5Encode(strUri + guid) + " " + guid;
            string strTheAuthKey = Des.Encode(strToEncrypt, Md5.MD5TwiceEncode(Password));

            reqMsg.Headers.Add(Consts.HTTP_HEADER_AUTH_USER, UserName);
            reqMsg.Headers.Add(Consts.HTTP_HEADER_AUTH_KEY, strTheAuthKey);
        }
Exemple #2
0
        private static void MakePrincipleHeader(WebRequest reqMsg, string strUri)
        {
            Guid guid = Guid.NewGuid();//为每次请求都生成一个不同的标识

            strUri = InternalHelper.GetEffectiveUri(strUri);
            string strToEncrypt  = Md5.MD5Encode(strUri + guid) + " " + guid;
            string strTheAuthKey = Des.Encode(strToEncrypt, Md5.MD5TwiceEncode(Token ?? ""));

            reqMsg.Headers.Add(Consts.HTTP_HEADER_AUTH_USER, Account);
            reqMsg.Headers.Add(Consts.HTTP_HEADER_AUTH_KEY, strTheAuthKey);

            reqMsg.Headers.Add(HttpRequestHeader.AcceptEncoding, "utf-8");
        }
Exemple #3
0
        //private void button1_Click(object sender, EventArgs e)
        //{
        //    if (radAes.Checked)
        //    {
        //        var aes = new Aes();
        //        try
        //        {
        //            txtOutput.Text = aes.Encrypt(txtInput.Text);
        //        }
        //        catch (Exception)
        //        {
        //            txtOutput.Text = aes.Decrypt(txtInput.Text);
        //        }
        //    }
        //    if (radBase64.Checked)
        //    {
        //        var b64 = new Base64();
        //        try
        //        {
        //            txtOutput.Text = b64.Encode(txtInput.Text);
        //        }
        //        catch (Exception)
        //        {
        //            txtOutput.Text = b64.Decode(txtInput.Text);
        //        }
        //    }
        //    if (radDes.Checked)
        //    {
        //        var des = new Des();
        //        try
        //        {
        //            txtOutput.Text = des.Encode(txtInput.Text);
        //        }
        //        catch (Exception)
        //        {
        //            txtOutput.Text = des.Decode(txtInput.Text);
        //        }
        //    }
        //    if (radShift.Checked)
        //    {
        //        var shift = new Shift();
        //        try
        //        {
        //            txtOutput.Text = shift.Encrypt(txtInput.Text);
        //        }
        //        catch (Exception)
        //        {
        //            txtOutput.Text = shift.Decrypt(txtInput.Text);
        //        }
        //    }
        //}

        private void button1_Click(object sender, EventArgs e)
        {
            if (radAes.Checked)
            {
                var aes = new Aes();
                txtOutput.Text = aes.Encrypt(txtInput.Text);
            }
            if (radBase64.Checked)
            {
                var b64 = new Base64();
                txtOutput.Text = b64.Encode(txtInput.Text);
            }
            if (radDes.Checked)
            {
                var des = new Des();
                txtOutput.Text = des.Encode(txtInput.Text);
            }
            if (radShift.Checked)
            {
                var shift = new Shift();
                txtOutput.Text = shift.Encrypt(txtInput.Text);
            }
        }
Exemple #4
0
 public static string MakeConfidentialMessage(string strToEnc)
 {
     return(Des.Encode(strToEnc, Md5.MD5TwiceEncode(Token)));
 }