# This program proves that the keyspace of the affine cipher is limited
# to less than len(SYMBOLS) ^ 2.

from books.CrackingCodesWithPython.Chapter14.affineCipher import encryptMessage, SYMBOLS
from books.CrackingCodesWithPython.Chapter13.cryptomath import gcd

message = 'Make things as simple as possible, but not simpler.'
for keyA in range(2, 80):
    key = keyA * len(SYMBOLS) + 1

    if gcd(keyA, len(SYMBOLS)) == 1:
        print(keyA, encryptMessage(key, message))

@@ -1,10 +1,40 @@
-# 
+%22%22%22Test affine cipher keyspace%0A%0A
 This pro
@@ -98,10 +98,8 @@
 ited
-%0A#
  to 
@@ -127,16 +127,155 @@
 ) %5E 2.%0A%0A
+Note:%0A    Tests every key from 2 through 80 and prints it with the encrypted message if the key and%0A    length of SYMBOLS have a gcd.%0A%22%22%22%0A%0A
 from boo
@@ -423,16 +423,33 @@
 rt gcd%0A%0A
+%0Adef main():%0A    
 message 
@@ -504,16 +504,20 @@
 mpler.'%0A
+    
 for keyA
@@ -534,16 +534,20 @@
 2, 80):%0A
+    
     key 
@@ -577,16 +577,20 @@
  1%0A%0A    
+   
+ 
 if gcd(k
@@ -614,16 +614,20 @@
 ) == 1:%0A
+    
         
@@ -668,8 +668,48 @@
 ssage))%0A
+%0A%0Aif __name__ == '__main__':%0A    main()%0A

Update Chapter14/affineKeyTest.py added docstring and wrapped in main() function