RSA cryptosystem

Up a level : Algebra and Arithmetic
Previous page : Finding 10000 decimals of pi
Next page : BigInt random numbers

RSA

On this page you can encode and decode RSA messages. It is to be seen as a toy system, even though it works.

See https://en.wikipedia.org/wiki/RSA_(cryptosystem) for more info on RSA.

The input text is first converted to Unicode numbers with three digits. Any number <100 is padded with a 0, so A will be converted to 065.  Then as many of  those numbers will be concatenated, as strings, as fits into the length of the key. Say p=2722429522727,  q=6172325836711 and e=31, then the key
n=pq=16803722081752658665430897. This has 26 digits, so we wold fit eight characters per number. (Not nine, since then the code for the first character must be less than 169.)  Say our message is
“The Magic Words are Squeamish Ossifrage”. The letter T is coded as 084, h as 104, and so on. This will turn our message to the numbers
084104101032077097103105,099032087111114100115032,
097114101032083113117101,097109105115104032079115 and
115105102114097103101 – the last containing just seven characters.

This is then encoded, number by number, by the RSA-algorithm to
00084104101032077097103105,00099032087111114100115032,
00097114101032083113117101,00097109105115104032079115,
00000115105102114097103101 -where extra zeroes are padded when necessary.

Decoded, using the value n and the secret exponent d=2439249979607965728881341 it will give us:
084104101032077097103105,099032087111114100115032,
097114101032083113117101,097109105115104032079115 and
115105102114097103101

This is the same as the original numbers, that then can be turned to a message again.

Up a level : Algebra and Arithmetic
Previous page : Finding 10000 decimals of pi
Next page : BigInt random numbersLast modified: Jul 3, 2022 @ 17:41