首页 新闻 会员 周边 捐助

求帮助代码注释!!!!我看不东这些代码!!谢谢!!

0
悬赏园豆:50 [待解决问题]

 

客户端代码

 

using System;

using System.Data;

using System.Configuration;

using System.Web;

using System.Security;

using System.Security.Cryptography;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using demo;

 

public partial class _Default : System.Web.UI.Page

{

    protected void Page_Load(object sender, EventArgs e)

    {

    }

    protected void Button1_Click(object sender, EventArgs e)

    {

        demo.Service aa = new Service();

        string info = this.TextBox1.Text;

        demo.UserInfo uu = aa.getSOAPHeader();

 

        System.Security.Cryptography.CspParameters param = new CspParameters();

        param.Flags = CspProviderFlags.UseMachineKeyStore;

 

        RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(param);

        rsa.FromXmlString(uu.RSAPublicKey);

 

        DESCryptoServiceProvider des = new DESCryptoServiceProvider();

        des.GenerateKey();

        uu.DESKey = rsa.Encrypt(des.Key, false);

      

        des.GenerateIV();

        uu.DESIV = rsa.Encrypt(des.IV, false);

 

        ICryptoTransform ict = des.CreateEncryptor();

        System.Text.ASCIIEncoding ascii = new System.Text.ASCIIEncoding();

        byte[] input = ascii.GetBytes(info);

        uu.name = ict.TransformFinalBlock(input, 0, input.GetLength(0));

      

        info = aa.getUserInfo(uu);

        this.Label1.Text = info;

    }

}

 

Web服务端代码

//SOAP头信息

using System;

using System.Data;

using System.Configuration;

using System.Web;

using System.Security.Cryptography;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

 

/// <summary>

/// UserInfo 的摘要说明

/// </summary>

public class UserInfo : System.Web.Services.Protocols.SoapHeader

{

    public byte[] name;

    public string RSAPublicKey;

    public byte[] DESKey;

    public byte[] DESIV;

    public UserInfo()

    {

        //name = "";

     }

   

}

 

//web服务

using System;

using System.Web;

using System.Security.Cryptography;

using System.Web.Services;

using System.Web.Services.Protocols;

 

 

[WebService(Namespace = "http://tempuri.org/")]

[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]

public class Service : System.Web.Services.WebService

{

    public UserInfo uinfo ;

    public Service()

    {

        RSACryptoServiceProvider rsa=new RSACryptoServiceProvider();

        uinfo = new UserInfo();

        uinfo.RSAPublicKey = rsa.ToXmlString(true);

    }

    [SoapHeader("uinfo")]

    [WebMethod]

    public string getUserInfo(UserInfo uinfo)

    {

        RSACryptoServiceProvider rsa= new RSACryptoServiceProvider();

        DESCryptoServiceProvider des = new DESCryptoServiceProvider();

 

        rsa.FromXmlString(uinfo.RSAPublicKey);

       

        byte[] _DESKey = rsa.Decrypt(uinfo.DESKey,false);

        byte[] _DESIV = rsa.Decrypt(uinfo.DESKey, false);

 

 

        des.Key = _DESKey;

        des.IV  = _DESIV;

        ICryptoTransform ict = des.CreateDecryptor();

        byte[] ret = ict.TransformFinalBlock(uinfo.name ,0,uinfo.name.Length);

       

        System.Text.ASCIIEncoding ascii = new System.Text.ASCIIEncoding();

        return ascii.GetString(ret,0,ret.Length);

    }

    [WebMethod]

    public UserInfo getSOAPHeader()

    {

        return uinfo;

    }

}

 

 

孤单的浪漫的主页 孤单的浪漫 | 初学一级 | 园豆:100
提问于:2010-11-10 10:23
< >
分享
所有回答(7)
0

加密的方式,不用看懂,知道怎么调用方法就行了~~~

路过秋天 | 园豆:4787 (老鸟四级) | 2010-11-10 11:29
0

对soapheader参数加密 调用web service

码尔代夫iimax | 园豆:3138 (老鸟四级) | 2010-11-10 14:46
0

加密算法我一直没看过,反正也不用你去写。知道怎么用就ok了!

茂茂 | 园豆:2902 (老鸟四级) | 2010-11-10 15:25
0

.net内置的加密

darren.yang | 园豆:251 (菜鸟二级) | 2010-11-10 16:38
0

单步调试,并输出相应的数据,相信你可以理解。

Astar | 园豆:40805 (高人七级) | 2010-11-10 17:11
0

单步调试吧。

itaozi | 园豆:1055 (小虾三级) | 2010-11-11 22:41
0

往VS环境里面一扔,什么都现出原型。。。

Tester Chen | 园豆:1690 (小虾三级) | 2010-11-17 17:18
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册