首页 新闻 会员 周边 捐助

vb.net代码转换成asp.net代码

0
悬赏园豆:20 [已解决问题] 解决于 2016-03-04 10:16
Public Shared Function Sign(VarPost As NameValueCollection) As String
        '读取私钥
        Dim fs As New FileStream(AppDomain.CurrentDomain.BaseDirectory & "\prkeynet.key", FileMode.Open)
        Dim sr As New StreamReader(fs)
        Dim KeyStr As String = sr.ReadToEnd.ToString

        Dim SignStr As String = ""
        For i As Integer = 0 To VarPost.Count - 1
            SignStr += VarPost.Get(i).ToString & "|"
        Next
         
        Dim RSA As New RSACryptoServiceProvider()
        RSA.FromXmlString(KeyStr)
        Dim AOutput As Byte() = RSA.SignData(Encoding.UTF8.GetBytes(SignStr.Substring(0, SignStr.Length - 1)), "SHA1")

        fs.Close()
        fs.Dispose()

        Return Convert.ToBase64String(AOutput)
    End Function
imluzhi的主页 imluzhi | 初学一级 | 园豆:37
提问于:2015-11-12 21:23
< >
分享
最佳答案
0
public string Sign(NameValueCollection varPost)
{
    var fs = new FileStream(AppDomain.CurrentDomain.BaseDirectory + "\prkeynet.key", FileMode.Open);
    var sr = new StreamReader(fs);
    var keyStr =  sr.ReadToEnd.ToString();
    var signStr = "";
    for(int i = 0; i <= varPost.Count - 1; i++){
        signStr += varPost.Get(i).ToString() + '|';
    }
    var RSA  = new RSACryptoServiceProvider();
    RSA.FromXmlString(keyStr)
    byte[]  AOutput = RSA.SignData(Encoding.UTF8.GetBytes(signStr.Substring(0, signStr.Length - 1)), "SHA1");

    fs.Close();
    fs.Dispose();

    return Convert.ToBase64String(AOutput);
}
       

大概看看吧。

收获园豆:20
幻天芒 | 高人七级 |园豆:37207 | 2015-11-13 09:06
其他回答(2)
0

vb.net 转ASP.NET什么鬼啊?

ASP.NET本身就包括了VB.NET语言的实现在内的,一个是架构一个是语言,转啥转啊。

爱编程的大叔 | 园豆:30844 (高人七级) | 2015-11-13 09:43
0

http://converter.telerik.com/

类似的VB C#互相转换的工具有很多,善用搜索。

winfa | 园豆:165 (初学一级) | 2015-12-03 21:56
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册