Python String/bytes as big number and back (last update: 2017-10-22, created: 2017-10-22) back to the list ↑
|
|||
Example code I've written as part of an answer of a question about RSA on one of the Polish programming forums. Please note it was meant as a general example, and not as RSA OpenSSL compatible method that is safe/well written in any way.
The *_hack methods are actually what I use on CTFs/etc when I need to implement this fast (i.e. implementation time has to be short, runtime doesn't matter). The methods without this suffix are more what you would expect. Please also note that I'm using Python's built-in bignum implementation. In (almost) any other language this would require either a library or a custom bignum implementation. def str2num(s): Output: Text: Hello World | |||
|