Mercurial > public > m209
annotate examples/decrypt.py @ 67:a2647b9fe107
Documented the M209's letter_count attribute.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sat, 20 Jul 2013 19:13:41 -0500 |
parents | 9341896b93f0 |
children |
rev | line source |
---|---|
bgneal@55 | 1 """Example of how to perform a decrypt operation using the standard |
bgneal@55 | 2 procedure. Assumes a key file named m209keys.cfg exists in the current directory |
bgneal@55 | 3 and contains the key list with indicator MB. |
bgneal@55 | 4 |
bgneal@55 | 5 """ |
bgneal@55 | 6 from m209.procedure import StdProcedure |
bgneal@55 | 7 from m209.keylist.config import read_key_list |
bgneal@55 | 8 |
bgneal@55 | 9 msg = ('IIPDU FHLMB LASGD KTLDO OSRMZ PWGEB HYMCB IKSPT IUEPF FUHEO NQTWI VTDPC' |
bgneal@55 | 10 ' GSPQX IIPDU FHLMB') |
bgneal@55 | 11 |
bgneal@55 | 12 proc = StdProcedure() |
bgneal@55 | 13 params = proc.set_decrypt_message(msg) |
bgneal@55 | 14 key_list = read_key_list('m209keys.cfg', params.key_list_ind) |
bgneal@55 | 15 if key_list: |
bgneal@55 | 16 proc.set_key_list(key_list) |
bgneal@55 | 17 plaintext = proc.decrypt() |
bgneal@55 | 18 print(plaintext) |
bgneal@55 | 19 else: |
bgneal@55 | 20 print("Key list '{}' not found".format(params.key_list_ind)) |