
Public-key cryptosystems based on factoring 103
sage: join(ms,’’)
’Withdraw one hundred dollars’
It will be convenient to put these commands into functions str2num and
num2str which translates a string into a single integer, and back again:
def str2num(s):
return ZZ(map(ord,s),256)
def num2str(n):
nl=n.digits(256)
return join(map(chr,nl),’’)
Now to demonstrate RSA with some non-trivia lly small integers first create
some large primes:
sage: p = next_prime(2^330)
sage: p
2187250724783011924372502227117621365353169430893212436425770
606409952999199375923223513177023053917
sage: q = next_prime(3^210)
sage: q
1568424042913152925468569828489075118463940614573029159280267 ...