---
title: "**Crack i n g C o d e s w i t h Python**"
id: "691"
type: "page"
slug: "crackingcodeswithpython"
published_at: "2026-07-17T05:31:28+00:00"
modified_at: "2026-07-17T14:10:40+00:00"
url: "https://preppers-paradise.com/library/crackingcodeswithpython/"
markdown_url: "https://preppers-paradise.com/library/crackingcodeswithpython.md"
excerpt: "An accessible introduction to classical cryptography using Python. Readers build and break ciphers including Caesar, transposition, Vigenère, and public-key styles while learning encryption mechanics, frequency analysis, and code-breaking techniques alongside core programming concepts."
taxonomy_category:
  - "Books"
  - "Free Teaser"
  - "Programming &amp; Development"
taxonomy_post_tag:
  - "al sweigart"
  - "ciphers"
  - "computer security"
  - "cryptography"
  - "data encryption"
  - "hacking"
  - "programming"
  - "python"
  - "tutorial"
---

# **Crack i n g C o d e s w i t h Python**

"Cracking Codes with Python" by Al Sweigart offers an accessible introduction to cryptography, guiding readers through building and breaking various ciphers using the Python programming language. The book covers fundamental coding concepts alongside practical applications for ciphers like Caesar, Transposition, Vigenère, and Public Key, teaching both the mechanics of encryption and techniques for code-breaking and frequency analysis.

This page is free — overview and chapter list only.
Full book: $2.99 USDC · Per chapter: $0.25 USDC
[Buy / open complete book](/library/complete/crackingcodeswithpython/) · [Complete book Markdown](/library/complete/crackingcodeswithpython.md)

## Chapters

1. [About The Technical Reviewers](/library/crackingcodeswithpython/01-about-the-technical-reviewers/) (Free teaser)
1. [How To Use This Book](/library/crackingcodeswithpython/02-how-to-use-this-book/) ($0.25)
1. [Starting Idle](/library/crackingcodeswithpython/03-starting-idle/) ($0.25)
1. [The Caesar Cipher](/library/crackingcodeswithpython/04-the-caesar-cipher/) ($0.25)
1. [Some Simple Math Expressions](/library/crackingcodeswithpython/05-some-simple-math-expressions/) ($0.25)
1. [Storing Values With Variables](/library/crackingcodeswithpython/06-storing-values-with-variables/) ($0.25)
1. [Working With Text Using String Values](/library/crackingcodeswithpython/07-working-with-text-using-string-values/) ($0.25)
1. [Printing Values With The Print Function](/library/crackingcodeswithpython/08-printing-values-with-the-print-function/) ($0.25)
1. [Writing Programs In Idles File Editor](/library/crackingcodeswithpython/09-writing-programs-in-idles-file-editor/) ($0.25)
1. [How The Hello World Program Works](/library/crackingcodeswithpython/10-how-the-hello-world-program-works/) ($0.25)
1. [Setting Up Comments And Variables](/library/crackingcodeswithpython/11-setting-up-comments-and-variables/) ($0.25)
1. [Sample Run Of The Caesar Cipher Program](/library/crackingcodeswithpython/12-sample-run-of-the-caesar-cipher-program/) ($0.25)
1. [Encrypting And Decrypting Symbols](/library/crackingcodeswithpython/13-encrypting-and-decrypting-symbols/) ($0.25)
1. [Displaying And Copying The Translated String](/library/crackingcodeswithpython/14-displaying-and-copying-the-translated-string/) ($0.25)
1. [Pract Ice Questions](/library/crackingcodeswithpython/15-pract-ice-questions/) ($0.25)
1. [Sample Run Of The Caesar Cipher Hacker Program](/library/crackingcodeswithpython/16-sample-run-of-the-caesar-cipher-hacker-program/) ($0.25)
1. [Using String Formatting To Display The Key And Decrypted Mes](/library/crackingcodeswithpython/17-using-string-formatting-to-display-the-key-and-decrypted-mes/) ($0.25)
1. [Creating The Encryption Program](/library/crackingcodeswithpython/18-creating-the-encryption-program/) ($0.25)
1. [Creating Your Own Functions With Def Statements](/library/crackingcodeswithpython/19-creating-your-own-functions-with-def-statements/) ($0.25)
1. [The List Data Type](/library/crackingcodeswithpython/20-the-list-data-type/) ($0.25)
1. [Augmented Assignment Operators](/library/crackingcodeswithpython/21-augmented-assignment-operators/) ($0.25)
1. [Using String Methods To Make User Input More Flexible](/library/crackingcodeswithpython/22-using-string-methods-to-make-user-input-more-flexible/) ($0.25)
1. [Writing The Output File](/library/crackingcodeswithpython/23-writing-the-output-file/) ($0.25)
1. [Source Code For The Detect English Module](/library/crackingcodeswithpython/24-source-code-for-the-detect-english-module/) ($0.25)
1. [The Dictionary Data Type](/library/crackingcodeswithpython/25-the-dictionary-data-type/) ($0.25)
1. [Implementing The Dictionary File](/library/crackingcodeswithpython/26-implementing-the-dictionary-file/) ($0.25)
1. [Counting The Number Of English Words In Message](/library/crackingcodeswithpython/27-counting-the-number-of-english-words-in-message/) ($0.25)
1. [Detecting English Words](/library/crackingcodeswithpython/28-detecting-english-words/) ($0.25)
1. [Source Code Of The Transposition Cipher Hacker Program](/library/crackingcodeswithpython/29-source-code-of-the-transposition-cipher-hacker-program/) ($0.25)
1. [Getting The Hacked Message](/library/crackingcodeswithpython/30-getting-the-hacked-message/) ($0.25)
1. [Pract Ice Questions 2](/library/crackingcodeswithpython/31-pract-ice-questions-2/) ($0.25)
1. [Multiple Assignment](/library/crackingcodeswithpython/32-multiple-assignment/) ($0.25)
1. [Choosing Valid Multiplicative Keys](/library/crackingcodeswithpython/33-choosing-valid-multiplicative-keys/) ($0.25)
1. [Finding Modular Inverses](/library/crackingcodeswithpython/34-finding-modular-inverses/) ($0.25)
1. [Summary](/library/crackingcodeswithpython/35-summary/) ($0.25)
1. [Calculating And Validating The Keys](/library/crackingcodeswithpython/36-calculating-and-validating-the-keys/) ($0.25)
1. [Writing The Encryption Function](/library/crackingcodeswithpython/37-writing-the-encryption-function/) ($0.25)
1. [Summary 2](/library/crackingcodeswithpython/38-summary-2/) ($0.25)
1. [The Affine Cipher Hacking Function](/library/crackingcodeswithpython/39-the-affine-cipher-hacking-function/) ($0.25)
1. [Summary 3](/library/crackingcodeswithpython/40-summary-3/) ($0.25)
1. [The Translatemessage Function](/library/crackingcodeswithpython/41-the-translatemessage-function/) ($0.25)
1. [Using Word Patterns To Decrypt](/library/crackingcodeswithpython/42-using-word-patterns-to-decrypt/) ($0.25)
1. [Source Code For The Simple Substitution Hacking Program](/library/crackingcodeswithpython/43-source-code-for-the-simple-substitution-hacking-program/) ($0.25)
1. [Sample Run Of The Simple Substitution Hacking Program](/library/crackingcodeswithpython/44-sample-run-of-the-simple-substitution-hacking-program/) ($0.25)
1. [Creating A Cipherletter Mapping](/library/crackingcodeswithpython/45-creating-a-cipherletter-mapping/) ($0.25)
1. [The Hacksimplesub Function](/library/crackingcodeswithpython/46-the-hacksimplesub-function/) ($0.25)
1. [Using Multiple Letter Keys In The Vigenre Cipher](/library/crackingcodeswithpython/47-using-multiple-letter-keys-in-the-vigenre-cipher/) ($0.25)
1. [Source Code For The Vigenre Cipher Program](/library/crackingcodeswithpython/48-source-code-for-the-vigenre-cipher-program/) ($0.25)
1. [Encrypting And Decrypting The Message](/library/crackingcodeswithpython/49-encrypting-and-decrypting-the-message/) ($0.25)
1. [Analyzing The Frequency Of Letters In Text](/library/crackingcodeswithpython/50-analyzing-the-frequency-of-letters-in-text/) ($0.25)
1. [Using Frequency Analysis On The Vigenre Cipher](/library/crackingcodeswithpython/51-using-frequency-analysis-on-the-vigenre-cipher/) ($0.25)
1. [Counting The Letters In A Message](/library/crackingcodeswithpython/52-counting-the-letters-in-a-message/) ($0.25)
1. [Reversing The Letter Lists With The Sort Method](/library/crackingcodeswithpython/53-reversing-the-letter-lists-with-the-sort-method/) ($0.25)
1. [Converting The Dictionary Items To A Sortable List](/library/crackingcodeswithpython/54-converting-the-dictionary-items-to-a-sortable-list/) ($0.25)
1. [Pract Ice Questions 3](/library/crackingcodeswithpython/55-pract-ice-questions-3/) ($0.25)
1. [About The Vigenre Dictionary Hacker Program](/library/crackingcodeswithpython/56-about-the-vigenre-dictionary-hacker-program/) ($0.25)
1. [Getting Factors Of Spacings](/library/crackingcodeswithpython/57-getting-factors-of-spacings/) ($0.25)
1. [Using Frequency Analysis To Break Each Subkey](/library/crackingcodeswithpython/58-using-frequency-analysis-to-break-each-subkey/) ($0.25)
1. [Source Code For The Vigenre Hacking Program](/library/crackingcodeswithpython/59-source-code-for-the-vigenre-hacking-program/) ($0.25)
1. [Finding Repeated Sequences](/library/crackingcodeswithpython/60-finding-repeated-sequences/) ($0.25)
1. [Finding The Most Common Factors](/library/crackingcodeswithpython/61-finding-the-most-common-factors/) ($0.25)
1. [Getting Letters Encrypted With The Same Subkey](/library/crackingcodeswithpython/62-getting-letters-encrypted-with-the-same-subkey/) ($0.25)
1. [Finding Possible Combinations Of Subkeys](/library/crackingcodeswithpython/63-finding-possible-combinations-of-subkeys/) ($0.25)
1. [Modifying The Constants Of The Hacking Program](/library/crackingcodeswithpython/64-modifying-the-constants-of-the-hacking-program/) ($0.25)
1. [The Unbreakable One Time Pad Cipher](/library/crackingcodeswithpython/65-the-unbreakable-one-time-pad-cipher/) ($0.25)
1. [Why The Two Time Pad Is The Vigenre Cipher](/library/crackingcodeswithpython/66-why-the-two-time-pad-is-the-vigenre-cipher/) ($0.25)
1. [What Is A Prime Number](/library/crackingcodeswithpython/67-what-is-a-prime-number/) ($0.25)
1. [Source Code For The Prime Numbers Module](/library/crackingcodeswithpython/68-source-code-for-the-prime-numbers-module/) ($0.25)
1. [How The Trial Division Algorithm Works](/library/crackingcodeswithpython/69-how-the-trial-division-algorithm-works/) ($0.25)
1. [The Dangers Of Using Textbook Rsa](/library/crackingcodeswithpython/70-the-dangers-of-using-textbook-rsa/) ($0.25)
1. [Beware The Mitm Attack](/library/crackingcodeswithpython/71-beware-the-mitm-attack/) ($0.25)
1. [Returning The Keys](/library/crackingcodeswithpython/72-returning-the-keys/) ($0.25)
1. [Converting A String Into A Block](/library/crackingcodeswithpython/73-converting-a-string-into-a-block/) ($0.25)
1. [The Mathematics Of Public Key Cipher Encryption And Decrypti](/library/crackingcodeswithpython/74-the-mathematics-of-public-key-cipher-encryption-and-decrypti/) ($0.25)
1. [Why We Cant Hack The Public Key Cipher](/library/crackingcodeswithpython/75-why-we-cant-hack-the-public-key-cipher/) ($0.25)
1. [Storing Blocks In Blockint](/library/crackingcodeswithpython/76-storing-blocks-in-blockint/) ($0.25)
1. [Merging The Message List Into One String](/library/crackingcodeswithpython/77-merging-the-message-list-into-one-string/) ($0.25)
1. [Calling The Main Function](/library/crackingcodeswithpython/78-calling-the-main-function/) ($0.25)
1. [Debugging The Reverse Cipher Program](/library/crackingcodeswithpython/79-debugging-the-reverse-cipher-program/) ($0.25)
1. [Summary 4](/library/crackingcodeswithpython/80-summary-4/) ($0.25)
