计算一个数模量在电力色丹(在权力的数量是相当大的)数模、权力、数量、电力

2023-09-03 04:18:48 作者:合拍病友

我想通过自己计算的RSA算法。我需要计算在一定功率的数目的模数。问题是,这个数字在某些功率可以得到相当大的。

I want to calculate the RSA algorithm by myself . I need to calculate the modulus of a number at a certain power. The thing is that that number at that certain power can get quite big.

下面是我想要的:

x = pow(n, p) % q

我怎样才能有效地确定X'

How can I efficiently determine x?

推荐答案

如果您使用的是.NET 4,我建议你看看BigInteger,甚至提供了ModPow方法做这一切在一个单一的操作:)

If you're using .NET 4, I suggest you look at BigInteger, which even provides the ModPow method to do it all in a single operation :)

BigInteger n = ...;
BigInteger p = ...;
BigInteger q = ...;
BigInteger x = BigInteger.ModPow(n, p, q);