I'm working with my own 91-numbers numerical system (unnonagesimal) in python 3.6 for RSA algorithm for my studies project. It works really fine but not with large numbers. Numbers I need it to work with are bigger than 1024 bits.
It doesn't work with some numbers, especially with those big ones.
The question is: Why doesn't it work?
Here's my code:
_unnonagesimal = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+=^/*?&<>()[]@%$#,;'`~|\"\\_"
def unnonagesimal_to_decimal(s):
return sum([_unnonagesimal.find(var) * len(_unnonagesimal) ** i
for i, var in enumerate(reversed(s))])
def decimal_to_unnonagesimal(n):
if n == 0:
return 0
else:
s = ""
while n != 0:
s += _unnonagesimal[n % len(_unnonagesimal)]
n = int(n / len(_unnonagesimal))
return s[::-1]
Where:
unnonagesimal_to_decimal(s)
converts unnonagesimal string s
into a decimal number.
and
decimal_to_unnonagesimal(n)
converts decimal int n
into an unnonagesimal number.