RSA in 12 lines of Python

--

I set myself a task to write a minimal number of lines to implement a full RSA key generation, encryption and decryption system, and I got it down to 12 lines (not including import statements). The code is [here]:

A test run shows it working:

Message=hello
p=242648958288128614541925147518101769011
q=299356840913214192252590475232148200447
N=72638625604016464006874651287120524699932001616388639276131104258310920947917
cipher=5847803746095553957863305890801268831081138920772806292673259864173015661385
decipher=hello

Don’t you just love Python?

--

--

Prof Bill Buchanan OBE FRSE
ASecuritySite: When Bob Met Alice

Professor of Cryptography. Serial innovator. Believer in fairness, justice & freedom. Based in Edinburgh. Old World Breaker. New World Creator. Building trust.