"Hacking Secret Ciphers with Python" programs

asweigart asweigart Last update: Apr 17, 2024

Code from Hacking Secret Ciphers with Python

This repo contains the source for the encryption and code breaking programs featured in the book Hacking Secret Ciphers with Python. Since the code in the book is at this point set in print, I'm only interested in receiving bug reports rather than refactors. But feel free to fork this repo!

Here's a general description of each of the files:

affineBreaker.py: Break Affine Cipher-encrypted messages.

affineCipher.py: Encrypt and decrypt using the Affine Cipher.

al_sweigart_privkey.txt: A sample private key file that is used by the rsaCipher.py program.

al_sweigart_pubkey.txt: A sample public key file that is used by the rsaCipher.py program.

buggy.py: Used as practice for using Python's debugger.

caesarBreaker.py: Break Caesar Cipher-encrypted messages.

caesarCipher.py: Encrypts and decrypts using the Caesar Cipher.

coinFlips.py: Used as practice for using Python's debugger.

detectEnglish.py: Used to detect if a string is English.

dictionary.txt: A dictionary file of English words, one per line.

encrypted_file.txt: A sample encrypted file from the

frankenstein.txt: A large text file sample. (The public domain novel Frankenstein.)

freqFinder.py: Module for gathering letter frequency statistics.

makeRsaKeys.py: Generate a public/private RSA key pair.

nullBreaker.py: Breaks Null Cipher-encrypted messages.

nullCipher.py: Encrypts and decrypts using the Null Cipher.

primeSieve.py: Generates prime numbers using the Sieve of Erastothenes algorithm

pyperclip.py: A module for copying and pasting to the clipboard. This source code isn't going to be featured in the book, and is only included so that people can test the programs that use it.

rabinMiller.py: Module for primality testing using the Rabin-Miller algorithm.

README.md: The file that you are reading right now, silly. :D

reverseCipher.py: Encrypts with the reverse "cipher", which just reverse the string.

rsaCipher.py: Encrypts and decrypts using the RSA Cipher.

simpleSubBreaker.py: Breaks Simple Substitution Cipher-encrypted messages.

simpleSubCipher.py: Encrypts and decrypts using the Simple Substitution Cipher.

simpleSubKeyword.py: Encrypts and decrypts using the Simple Substitution Cipher, using an English word for the key.

transpositionBreaker.py: Breaks Transposition Cipher-encrypted messages.

transpositionCipherFile.py: Encrypts and decrypts files using the Transposition Cipher.

transpositionDecrypt.py: Decrypts messages using the Transposition Cipher.

transpositionEncrypt.py: Encrypts messages using the Transposition Cipher.

transpositionFileBreaker.py: Breaks Transposition Cipher-encrypted files.

transpositionTest.py: Tests to see if the Transposition Cipher program works.

vigenereBreaker.py: Breaks Vigenere Cipher-encrypted messages.

vigenereCipher.py: Encrypts and decrypts using the Vigenere Cipher.

Tags:

Subscribe to our newsletter