我使用RSA算法进行加密/解密,为了解密文件,你必须处理一些非常大的值.更具体地说,像
P = C^d % n
= 62^65 % 133
Run Code Online (Sandbox Code Playgroud)
现在这真的是唯一不适当的计算.我尝试过使用Matt McCutchen的BigInteger库,但是在链接过程中我遇到了很多编译错误,例如:
encryption.o(.text+0x187):encryption.cpp: undefined reference to `BigInteger::BigInteger(int)'
encryption.o(.text+0x302):encryption.cpp: undefined reference to `operator<<(std::ostream&, BigInteger const&)'
encryption.o(.text$_ZNK10BigIntegermlERKS_[BigInteger::operator*(BigInteger const&) const]+0x63):encryption.cpp: undefined reference to `BigInteger::multiply(BigInteger const&, BigInteger const&)'
Run Code Online (Sandbox Code Playgroud)
所以我想知道处理RSA算法产生的真正大整数的最佳方法是什么.
我听说有可能将你的变量声明为双倍长,所以......
long long decryptedCharacter;
Run Code Online (Sandbox Code Playgroud)
但我不确定可以存储多大的整数.
好吧,例如,我尝试使用dev C++编译并运行以下程序:
#include iostream
#include "bigint\BigIntegerLibrary.hh"
using namespace std;
int main()
{
BigInteger a = 65536;
cout << (a * a * a * a * a * a * a * a);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
然后我得到了那些错误.
Derek,我认为通过包含BigIntegerLibrary.hh文件,编译器会经历并编译它将使用的所有必要文件. …
我正在尝试用C++实现BigInteger类.但是,首先,我有一个基本问题,"基础数据"如何表示?例如,最愚蠢的方法是使用固定(或动态)char数组并在char中存储每个整数的整数.但是,好吧,这是一种非常愚蠢的方式,我在这里是为了你的建议.