如何解决返回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:
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。