Errata

If you find any typos, please email them to [email protected]. (Apologies in advance if I haven't posted your errata submission yet or failed to give credit. Please email me to correct this.)

Additional errata is available on the No Starch Press website.

Chapter 16 - Programming the Simple Substitution Cipher

On pages 209 and 212, line 14 of the simpleSubcipher.py program should change from if keyIsValid(myKey): to if not keyIsValid(myKey): (Thanks to Hamid R.)

Chapter 22 - Finding and Generating Prime Numbers

The isPrime() function in the primeNum.py file returns False if a prime number in LOW_PRIMES is passed to it. It can be fixed by setting lines 83 to 88 to the following: (Thanks to David K.)

  1.     # See if any of the low prime numbers can divide num:
  2.     for prime in LOW_PRIMES:
  3.         if (num == prime):
  4.             return True
  5.         if (num % prime == 0):
  6.             return False

Chapter 23 - Generating Keys for the Public Key Cipher

I made a copy/paste mistake with the code in makePublicPrivateKeys.py and the two parts that say "publicKey" should be "privateKey". On page 341, this one line of code needs to be changed from this:

64. print('The private key is a %s and a %s digit number.' % (len(str(publicKey[0])), len(str(publicKey[1]))))

to this:

64. print('The private key is a %s and a %s digit number.' % (len(str(privateKey[0])), len(str(privateKey[1]))))