Buy New
-44%
$22.30$22.30
FREE delivery Monday, May 11 on orders shipped by Amazon over $35
Ships from: Amazon.com Sold by: Amazon.com
Used - Good
$5.26$5.26
$3.99 delivery Thursday, May 14
Ships from: HPB-Red Sold by: HPB-Red
Sorry, there was a problem.
There was an error retrieving your Wish Lists. Please try again.Sorry, there was a problem.
List unavailable.
Download the free Kindle app and start reading Kindle books instantly on your smartphone, tablet, or computer - no Kindle device required.
Read instantly on your browser with Kindle for Web.
Using your mobile phone camera - scan the code below and download the Kindle app.
Follow the author
OK
Cracking Codes with Python: An Introduction to Building and Breaking Ciphers Illustrated Edition
Purchase options and add-ons
After a crash course in Python programming basics, you’ll learn to make, test, and hack programs that encrypt text with classical ciphers like the transposition cipher and Vigenère cipher. You’ll begin with simple programs for the reverse and Caesar ciphers and then work your way up to public key cryptography, the type of encryption used to secure today’s online transactions, including digital signatures, email, and Bitcoin.
Each program includes the full code and a line-by-line explanation of how things work. By the end of the book, you’ll have learned how to code in Python and you’ll have the clever programs to prove it!
You’ll also learn how to:
- Combine loops, variables, and flow control statements into real working programs
- Use dictionary files to instantly detect whether decrypted messages are valid English or gibberish
- Create test programs to make sure that your code encrypts and decrypts correctly
- Code (and hack!) a working example of the affine cipher, which uses modular arithmetic to encrypt a message
- Break ciphers with techniques such as brute-force and frequency analysis
There’s no better way to learn to code than to play with real programs. Cracking Codes with Python makes the learning fun!
- ISBN-101593278225
- ISBN-13978-1593278229
- EditionIllustrated
- PublisherNo Starch Press
- Publication dateJanuary 23, 2018
- LanguageEnglish
- Dimensions7.05 x 0.94 x 9.25 inches
- Print length416 pages
Frequently bought together

Deals on related products
Customers also bought or read
- The Big Book of Small Python Projects: 81 Easy Practice Programs
Paperback$31.86$31.86Delivery Mon, May 11 - Impractical Python Projects: Playful Programming Activities to Make You Smarter
Paperback$21.17$21.17Delivery May 14 - 18 - Black Hat Python, 2nd Edition: Python Programming for Hackers and Pentesters
Paperback$29.94$29.94Delivery Mon, May 11 - Beyond the Basic Stuff with Python: Best Practices for Writing Clean Code
Paperback$26.54$26.54$3.99 delivery May 26 - Jun 2 - Python Crash Course, 3rd Edition: A Hands-On, Project-Based Introduction to Programming#1 Best SellerIntroductory & Beginning Programming
Paperback$27.53$27.53Delivery Mon, May 11 - Practical Packet Analysis, 3rd Edition: Using Wireshark to Solve Real-World Network Problems
Paperback$35.06$35.06FREE delivery Mon, May 11 - Learn to Code by Solving Problems: A Python Programming Primer
Paperback$23.40$23.40Delivery May 13 - 14 - Object-Oriented Python: Master OOP by Building Games and GUIs
Paperback$35.96$35.96FREE delivery May 16 - 18 - Network Basics for Hackers: How Networks Work and How They Break#1 Best SellerLinux Applications
Paperback$39.32$39.32FREE delivery Tue, May 12 - Serious Cryptography, 2nd Edition: A Practical Introduction to Modern Encryption
Paperback$43.50$43.50FREE delivery Mon, May 11 - Math for Deep Learning: What You Need to Know to Understand Neural Networks
Paperback$35.68$35.68FREE delivery Mon, May 11 - Dive Into Algorithms: A Pythonic Adventure for the Intrepid Beginner
Paperback$34.91$34.91Delivery Mon, May 11 - Serious Python: Black-Belt Advice on Deployment, Scalability, Testing, and More
Paperback$25.00$25.00Delivery Mon, May 11 - Automate the Boring Stuff with Python, 2nd Edition: Practical Programming for Total Beginners
Paperback$23.47$23.47Delivery Mon, May 11 - Cryptanalysis: A Study of Ciphers and Their Solution (Dover Brain Games & Puzzles)
Paperback$15.95$15.95Delivery Mon, May 11 - How Computers Really Work: A Hands-On Guide to the Inner Workings of the Machine
Paperback$28.01$28.01$3.99 delivery May 19 - 26 - The Ultimate Kali Linux Book: Harness Nmap, Metasploit, Aircrack-ng, and Empire for cutting-edge pentesting
Paperback$35.33$35.33FREE delivery Tue, May 12 - Math Adventures with Python: An Illustrated Guide to Exploring Math with Code
Paperback$20.10$20.10FREE delivery May 14 - 19 - Modeling and Simulation in Python: An Introduction for Scientists and Engineers
Paperback$30.63$30.63$3.99 delivery Fri, May 29 - How Cybersecurity Really Works: A Hands-On Guide for Total Beginners
Paperback$23.08$23.08Delivery Mon, May 11 - Doing Math with Python: Use Programming to Explore Algebra, Statistics, Calculus, and More!
Paperback$31.39$31.39Delivery Tue, May 12 - Think Like a Programmer: An Introduction to Creative Problem Solving
Paperback$23.63$23.63Delivery Mon, May 11 - Gray Hat Python: Python Programming for Hackers and Reverse Engineers
Paperback$30.11$30.11$3.99 delivery May 26 - Jun 2 - The Code Book: The Science of Secrecy from Ancient Egypt to Quantum Cryptography
Paperback$10.57$10.57Delivery Mon, May 11 - Hacking APIs: Breaking Web Application Programming Interfaces
Paperback$32.99$32.99Delivery Mon, May 11 - Data Structures the Fun Way: An Amusing Adventure with Coffee-Filled Examples
Paperback$30.99$30.99Delivery Mon, May 11
Editorial Reviews
Review
—Ray Doyle, The Ethical Hacker Network
“I recommend this book for anyone who wants to learn Python/programming and is interested in security or puzzles.”
—Jeanne Boyarsky, Code Ranch
“A fantastic programming and cryptography course for any high school-aged child.”
—The Old Schoolhouse Magazine
About the Author
Product details
- Publisher : No Starch Press
- Publication date : January 23, 2018
- Edition : Illustrated
- Language : English
- Print length : 416 pages
- ISBN-10 : 1593278225
- ISBN-13 : 978-1593278229
- Item Weight : 1.75 pounds
- Reading age : 12 years and up
- Dimensions : 7.05 x 0.94 x 9.25 inches
- Best Sellers Rank: #623,452 in Books (See Top 100 in Books)
- #83 in Computer Cryptography
- #84 in Web Encryption
- #483 in Python Programming
- Customer Reviews:
About the author

Al Sweigart is a software developer and tech book author living in Houston. He has written several programming books for beginners, including Automate the Boring Stuff with Python. His books are freely available under a Creative Commons license at his website https://inventwithpython.com.
Related products with free delivery on eligible orders
Customer reviews
Customer Reviews, including Product Star Ratings help customers to learn more about the product and decide whether it is the right product for them.
To calculate the overall star rating and percentage breakdown by star, we don’t use a simple average. Instead, our system considers things like how recent a review is and if the reviewer bought the item on Amazon. It also analyzed reviews to verify trustworthiness.
Learn more how customers reviews work on AmazonCustomers say
Generated from the text of customer reviewsSelect to learn more
Reviews with images
Learn about computers, programming, and secret codes - all in one book!
Top reviews from the United States
- 5 out of 5 stars
An excellent book of Python exercises and basic cryptography primer!
Reviewed in the United States on September 25, 2018Full Disclosure: I solicited Mr. Sweigart for an eBook copy of this book for review purposes. This was AFTER purchasing the original Hacking Secret Ciphers book for Python 2 around 3 years ago and AFTER purchasing a physical copy of Cracking Codes immediately upon release based solely on my love for the previous installment. If it makes you feel any better, he got me the eBook months ago, and I'm dreadfully late on my review.
I'm a huge fan of Mr. Sweigart's work. I found Hacking Secret Ciphers to be a brilliant primer on basic Python programming practices, and find that it has only been refined and updated in Cracking Codes. Many friends have expressed an interest in what I do and asked me where to begin to learn programming concepts, and I frequently point them toward Python and Mr. Sweigart's resources.
Cracking Codes walks you through several different methods of encoding messages with different ciphers using the Python programming language. From a simple Caesar cipher all the way through an implementation of the textbook RSA cipher. He walks you through from basic data types and decision structures through loops, data structures, common Python modules, and other advanced concepts. You read from and write to files, and learn to powerfully process and transform text with Python.
I frequently use Hacking Secret Ciphers/Cracking Codes and Automate The Boring Stuff as references for writing basic Python programs. They're outstanding resources, and it's a joy to go back through Cracking Codes, retype all the exercises, and troubleshoot them until they run. The diff tool on Mr. Sweigart's InventWithPython site is a godsend, and the ability to run the source code to see what my code should look like when it executes has helped me pass many a roadblock.
I don't quite understand how every cipher works or why it's difficult to hack, but I do generally get what each program is doing at any given point, and you can, too. If you don't quite get cryptography, this is also a neat way to look under the hood and get some of the basic concepts. It's pretty wild to see a computer hack a cipher in seconds that would take a human hours, days, or months -- if they could solve it at all.
An excellent and entertaining book of exercises. I wholeheartedly suggest it, especially for teens and adults interested in computer science and programming. Thank you for another great book, Mr. Sweigart!
30 people found this helpfulSending feedback...Sending feedback...HelpfulThank you for your feedback.Sorry, we failed to record your vote. Please try againThanks, we'll investigate in the next few days.Sorry, We failed to report this review. Please try again - 5 out of 5 stars
Learn about computers, programming, and secret codes - all in one book!
Reviewed in the United States on May 19, 2021Cracking Codes with Python is a fantastic introduction to the Python programming language -- and coding in general -- using the super-fun theme of codebreaking. What's especially fun about this approach is that you can use these secret codes to send messages to your friends -- it's way better than invisible ink. As a student of computer history, I really appreciated the historical context provided for why codebreaking and ciphers are so important to the history of computers and technology. It's also great that the book provides a companion website with answers to all the practice problems at the end of each chapter, so that you can easily check your work.
I've recommended this book to folks who want to learn to code, and I'll keep doing so! By the end of it, you'll become quite the code-breaker and also a great Python programmer! I hope you enjoy it!
5 out of 5 starsLearn about computers, programming, and secret codes - all in one book!
Reviewed in the United States on May 19, 2021Cracking Codes with Python is a fantastic introduction to the Python programming language -- and coding in general -- using the super-fun theme of codebreaking. What's especially fun about this approach is that you can use these secret codes to send messages to your friends -- it's way better than invisible ink. As a student of computer history, I really appreciated the historical context provided for why codebreaking and ciphers are so important to the history of computers and technology. It's also great that the book provides a companion website with answers to all the practice problems at the end of each chapter, so that you can easily check your work.
I've recommended this book to folks who want to learn to code, and I'll keep doing so! By the end of it, you'll become quite the code-breaker and also a great Python programmer! I hope you enjoy it!
One person found this helpfulSending feedback...Sending feedback...HelpfulThank you for your feedback.Sorry, we failed to record your vote. Please try againThanks, we'll investigate in the next few days.Sorry, We failed to report this review. Please try again - 5 out of 5 stars
More about learning Python than it is about Cracking Codes
Reviewed in the United States on March 15, 2018As a Python tutorial, it is superb - comprehensive, well organized and painless. Follow along with the exercises and you'll end up with a good working knowledge of the language. Each succeeding chapter introduces more and more complex and useful language constructs, each of which is identified in the accompanying text and clearly explained. Indeed, it is the use of constructs like lists and dictionaries that make Python the very valuable and powerful scripting tool that it is.
As a Code Cracking tutorial, it is, as declared in the book sub-title, an "Introduction". You'll see how various algorithmic strategies can be used against comparatively simple ciphers. The techniques include frequency analysis, word pattern matching and dictionary tests for decrypted text.
But the book is more about Learning Python than it is about Cracking Codes. Upon completing it you'll emerge a journeyman Python programmer and a novice cryptographer.
57 people found this helpfulSending feedback...Sending feedback...HelpfulThank you for your feedback.Sorry, we failed to record your vote. Please try againThanks, we'll investigate in the next few days.Sorry, We failed to report this review. Please try again - 4 out of 5 stars
Perfect book for those interested in cryptography & learning Python3
Reviewed in the United States on January 31, 2019I would have loved to give 5 star but the bottom right corner came slightly damaged including cover. Outside that you can tell it is a new book.
Having an interest in cryptography & Network Security, this book makes learning python more interesting & useful.
Highly recommended.
6 people found this helpfulSending feedback...Sending feedback...HelpfulThank you for your feedback.Sorry, we failed to record your vote. Please try againThanks, we'll investigate in the next few days.Sorry, We failed to report this review. Please try again - 5 out of 5 stars
Excellent Resource!
Reviewed in the United States on September 26, 2018Prior to picking this book up I had made various attempts to learn how to program. I would go good for a while, but then I would get bored with it and move onto something else. The practice codes that other sources provide, just don't seem to hold interest due to them not really being useful. However, Cracking Codes with Python gets right into producing something that is comprehensive and useful. In this book you learn by doing. Then he walks you through line by line and explains everything in such a way that I gained an understanding of previously misunderstood concepts.
16 people found this helpfulSending feedback...Sending feedback...HelpfulThank you for your feedback.Sorry, we failed to record your vote. Please try againThanks, we'll investigate in the next few days.Sorry, We failed to report this review. Please try again - 5 out of 5 stars
Good stuff
Reviewed in the United States on June 13, 2018Decent content, should keep a beginner busy for some time. I picked project in there and modified it so it can decode and code stuff the way I like it and added a some what UI to it. Covers most of the basics, not very deeply though, but in my opinion good enough. Would recommend, but if ur looking into cyber security, look else where, as the encryption technique in here is really just practice for newer engineers. If your looking to start your python career somewhere and specifically cyber security, this is much better than the other books on the basics.
10 people found this helpfulSending feedback...Sending feedback...HelpfulThank you for your feedback.Sorry, we failed to record your vote. Please try againThanks, we'll investigate in the next few days.Sorry, We failed to report this review. Please try again - 5 out of 5 stars
Enjoayble
Reviewed in the United States on November 18, 2021Good tutorial of basic python programming with the added bonus of interesting introduction to encrypting and decrypting old ciphers. It's probably the only tech book I ever read from cover to cover.
3 people found this helpfulSending feedback...Sending feedback...HelpfulThank you for your feedback.Sorry, we failed to record your vote. Please try againThanks, we'll investigate in the next few days.Sorry, We failed to report this review. Please try again - 5 out of 5 stars
Does what the title says
Reviewed in the United States on January 6, 2020Great Book really breaks down the fundamentals of cracking.
Sending feedback...Sending feedback...HelpfulThank you for your feedback.Sorry, we failed to record your vote. Please try againThanks, we'll investigate in the next few days.Sorry, We failed to report this review. Please try again
Top reviews from other countries
no-panic5 out of 5 starsGreat Book!
Reviewed in Germany on September 16, 2021A great book, but only for those who are programming Python for the first time and also have no idea about the history of cryptography. But nothing else has been promised.
One can get into Python programming and cryptography without any prior knowledge. Each chapter introduces successively further into Python programming and at the same time into the history of cryptography.
The theory, the code and also the examples are very well explained.
Also, the presentation as an ebook for Kindle is also well done, which is not a given with technical books.
Sending feedback...Thanks, we'll investigate in the next few days.Sorry, We failed to report this review. Please try again
Wayne5 out of 5 starsLooking forward to the study.
Reviewed in Australia on February 6, 2026I haven't sat down in earnest to study it. But, having flicked through the contents, it seems an good way to learn.
Sending feedback...Thanks, we'll investigate in the next few days.Sorry, We failed to report this review. Please try again
Federico5 out of 5 starsIl miglior libro da affiancare alla teoria
Reviewed in Italy on March 17, 2022Sono uno studente del corso Cryptography e cercavo un libro che si approcciasse all'aspetto pratico della crittografia utilizzando Python e ho trovato questo MAGNIFICO libro. È proprio quello che cercavo!
Il libro è molto ben strutturato seguendo la tipica impronta americana che si focalizza più sulla pratica che sulla teoria (che ho apprezzato molto).
La qualità del libro è notevole e la carta è buona, lo consiglio a tutti gli interessati alla materia.

5 out of 5 starsIl miglior libro da affiancare alla teoria
Reviewed in Italy on March 17, 2022Sono uno studente del corso Cryptography e cercavo un libro che si approcciasse all'aspetto pratico della crittografia utilizzando Python e ho trovato questo MAGNIFICO libro. È proprio quello che cercavo!
Il libro è molto ben strutturato seguendo la tipica impronta americana che si focalizza più sulla pratica che sulla teoria (che ho apprezzato molto).
La qualità del libro è notevole e la carta è buona, lo consiglio a tutti gli interessati alla materia.
Sending feedback...Thanks, we'll investigate in the next few days.Sorry, We failed to report this review. Please try again
Anustup kanrar5 out of 5 stars5 stars ! Awesome page and cover quality
Reviewed in India on April 2, 2021Loved it ! 😁 Fastest delivery by Amazon! The page quality and cover is awesome
Sending feedback...Thanks, we'll investigate in the next few days.Sorry, We failed to report this review. Please try again
Gr3g0ry5 out of 5 starsGreat Book
Reviewed in Canada on February 1, 2020I'm addicted to these No starch Python books.
Cracking Codes is a great starting point for ciphers and encryprions. Well explained easy to follow.
Worth every cent!!
Sending feedback...Thanks, we'll investigate in the next few days.Sorry, We failed to report this review. Please try again













