-2

I am fairly new to Python and am currently creating a "RSA Encryption" program to send Secret messages to peers. I have the program completed, but run into issues with computations. I keep getting an overflow error because the numbers I am trying to crunch are too large for native python. Unassigned 256 bit numbers would be my ideal case, however I am having issues finding a library that supports them.I have also read that you can compress numbers into a more manageable format, however I have no direction or thought on how to do that.

If you have any proposed solutions to my issue It would be greatly appreciated! thanks for your time!

jpp
  • 159,742
  • 34
  • 281
  • 339

1 Answers1

4

Python supports arbitrary precision integers natively:

$ python3
Python 3.6.5 (default, Mar 29 2018, 18:20:46) 
[GCC 8.0.1 20180317 (Red Hat 8.0.1-0.19)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 2**256
115792089237316195423570985008687907853269984665640564039457584007913129639936
>>> 2**512
13407807929942597099574024998205846127479365820592393377723561443721764030073546976801874298166903427690031858186486050853753882811946569946433649006084096

But when you use some number crunching frameworks, like for example NumPy, then it will use platform native integers, which are limited usually to 64 bits.

Tometzky
  • 22,573
  • 5
  • 59
  • 73
  • thanks for the quick answer! the number i'm looking at right now is closer to 223^4493, I may need to rethink how this encryption system works, because this number seems absurdly large. and this is the case when my prime numbers i use to generate the key are only double digits. if i wanted prime numbers with 4 or 5 digits the number would get.... to large. – Christian Potts Jun 11 '18 at 04:03