gmp_pow() will not accept a GMP number for exponent

筅森魡賤 提交于 2019-12-13 06:15:03

问题


I am playing around in PHP with RSA and big numbers. I need to be able to take numbers to the power of an exponent that has ~256 to ~512 bytes using gmp_pow(). Does anyone have any suggestions?


回答1:


You should use gmp_powm() which automatically reduces the intermediate values to be less than the modulus value. This exactly what you want for RSA.

gmp_pow() doesn't accept an exponent large than a long since the intermediate values will be larger than the addressable memory in your computer.



来源:https://stackoverflow.com/questions/16255936/gmp-pow-will-not-accept-a-gmp-number-for-exponent

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!