计算一个数模量在电力色丹(在权力的数量是相当大的) [英] Calculate the modulus of a number at a certan power (the number at that power is quite big)

查看:152
本文介绍了计算一个数模量在电力色丹(在权力的数量是相当大的)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过自己计算的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,我建议你看看<一href="http://msdn.microsoft.com/en-us/library/system.numerics.biginteger.aspx"><$c$c>BigInteger,甚至提供了<一个href="http://msdn.microsoft.com/en-us/library/system.numerics.biginteger.modpow.aspx"><$c$c>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);

这篇关于计算一个数模量在电力色丹(在权力的数量是相当大的)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆