简体   繁体   English

在matlab中计算大数量的幂

[英]calculating large number powers in matlab

I am trying to figure out how to compute large powers of huge numbers in matlab to do RSA encryption. 我试图弄清楚如何在matlab中计算大数字的大功率来进行RSA加密。

For example: A 50+ digit integer raised to the power of 999999. 例如:一个50+数字整数,增加到999999的幂。

You can use exponentiation by squaring: 您可以通过平方使用取幂:

https://en.wikipedia.org/wiki/Exponentiation_by_squaring https://en.wikipedia.org/wiki/Exponentiation_by_squaring

So the end result will be around 1e49^1e6 = 1e49000000 . 所以最终结果将是1e49^1e6 = 1e49000000 This is too large a number for any basic matlab datatype to hold. 对于要保留的任何基本matlab数据类型,这个数字太大了。 A solution is to use the vpi toolbox of the file exchange; 一种解决方案是使用文件交换的vpi工具箱 ; it can handle large numbers, at the cost of speed. 它可以以速度为代价处理大量数字。

A better solution would exist in getting your end objective on a different manner; 在以不同的方式实现最终目标时,将存在更好的解决方案; ie redefine the formulas to get the final result.. 即重新定义公式以获得最终结果..

We need to implement some form of large number data type 我们需要实现某种形式的大数据类型
For C this is done using GMP Multiprecision library or LibToMMath Library 对于C,这是使用GMP Multiprecision库或LibToMMath库完成的
There are many others as well 还有很多其他的
For Matlab may be this will be helpful >>> LInK <<< 对于Matlab可能会有所帮助>>> LInK <<<

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM