返回BigInteger值c#的问题

问题描述

嗨,我正在使用 Signalr 编写一个简单的客户端/服务器应用程序,但我遇到了一个无法解决的问题。

在客户端,我像这样调用服务器方法

BigInteger methodresponse = await _hubProxy.Invoke<BigInteger>("e50a3a806adcca88f1e7472da6e710b0f92202a93e4e47d6cde948dedb2e1206",PublicEncryption(Encoding.UTF8.GetBytes(licensekey)));

methodresponse 是服务器的返回值

和服务器代码是:

    public BigInteger e50a3a806adcca88f1e7472da6e710b0f92202a93e4e47d6cde948dedb2e1206(byte[] checkstring)
    {
        LoadPrivateFromXml();
        byte[] inputstring = PrivateDecryption(checkstring);
        //Convert Bytes to string
        string nobytes = Encoding.ASCII.GetString(inputstring);

        PaillierCryptosys paillier = new PaillierCryptosys();

        int length = nobytes.Length;

        //Our 4 chosen values to play with
        BigInteger m1 = new BigInteger(length);
        BigInteger em1 = paillier.Encryption(m1);
        return em1;
    }

我的问题是在服务器上调试 em1 的值是我想要的值,一个非常大的 BigInteger 值但是当我检查来自服务器的响应时它是 {"R":{"dataLength": 32},"I":"1"} 客户端收到值 0

我已经在网上搜索了几个小时,但我似乎无法理解为什么会发生这种情况

编辑: 我会附上一些调试的照片

Debugging server we can see the true value of em1

Debugging client we can see what we recieve

编辑2: 完整的客户端方法代码

            BigInteger methodresponse1= await _hubProxy.Invoke<BigInteger>("e50a3a806adcca88f1e7472da6e710b0f92202a93e4e47d6cde948dedb2e1206",PublicEncryption(Encoding.UTF8.GetBytes(licensekey)));

            BigInteger methodresponse2= await _hubProxy.Invoke<BigInteger>("e50a3a806adcca88f1e7472da6e710b0f92202a93e4e47d6cde948dedb2e1206",PublicEncryption(Encoding.UTF8.GetBytes(timestamp.ToString())));

            PaillierCryptosys paillier = new PaillierCryptosys();
            BigInteger em1xem3 = (methodresponse1 * methodresponse2) % paillier.nsqr;
            MessageBox.Show(Convert.ToString(paillier.Decryption(em1xem3)));

            if (paillier.Decryption(em1xem3) == 47)
            {
                MessageBox.Show($"Success decrypted text [{paillier.Decryption(em1xem3)}] is equal to 47");
            }
            else 
            {
                MessageBox.Show(paillier.Decryption(em1xem3).ToString());
                MessageBox.Show("Failed");
            }

编辑 3:

尝试作为字符串问题

Trying as a string issue

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)