This text was written for use in an introductory course in cryptography. It starts with a discussion of classical cryptosystems (like the Caesar cipher), followed by the mathematics of breaking these classical cryptosystems. It then moves on to modern cryptosystems (like RSA or elliptic curve cryptography). Along the way, there’s a discussion of a variety of mathematical ideas, including the basics of number theory and probability theory.

I began writing this text on 2022-10-28 and it was last updated on 2024-04-18.

There are likely many typos and errors. They are entirely my fault, and alerting me to any you find would be much appreciated!


This text was written with Math 187A at UC San Diego in mind. This course was designed Adriano Garsia and Alina Bucur. I drew content from course materials (eg, lecture slides) prepared by them. In addition to this, I also drew content from materials by Matthias Strauch for a similar course he teaches at Indiana University, and from many other resources, including the SageMath Wiki as well as the following books:

Comments and feedback from the students and TAs of Math 187A in Winter 2023, and from Aranya Lahiri and his Math 187A students in Spring 2023, were indispensable.

Software used in the making of this text includes SageMath (and SageCell), KaTeX, Jekyll (with jekyll-pandoc), and probably other things I’m forgetting to mention.


This text is open-source and copylefted under CC BY-SA 4.0.