## Cryptography with Python

First posted: January 30, 2007

Click to activate, click play button
( 8 mins 20 seconds)

If you're new to cryptography, I should explain that the literature is full of references to Bob, Alice and Eve, where Bob and Alice represent two people wishing to exchange a secret, and Eve is the "evil principle," always trying to listen in and discover why Bob and Alice are sneaking around, using encryption.

I call Eve the "evil principle," but of course cryptography wouldn't even be a discipline were it not for the pressure she faithfully and consistently puts on Alice and Bob et al to remain on top of their game.

I recommend Donald Knuth's discussion of RSA in Vol. 3 of The Art of Computer Programming for some helpful practical advice. Note that RSA is relatively slow and may be used simply for the first step of exchanging a session key, after which an older but faster symmetric key algorithm might be used.

Note that Alice's computer is able to generate a secret d, corresponding to her public key N, only because her computer knows N's factors p and q and therefore N's totient (p-1)(q-1). These factors get thrown away after d is obtained and provided N is sufficiently large, we don't currently have techniques for factoring it again, nor any other means to compute d.