From f9c6636f8ba70544bb9f4b8e9fc7450c104fc76f Mon Sep 17 00:00:00 2001 From: Rich Wareham Date: Fri, 17 Sep 2010 12:05:30 +0100 Subject: [PATCH] move the main body into a main() function --- generate_key.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/generate_key.py b/generate_key.py index a02f44f..947f8a1 100755 --- a/generate_key.py +++ b/generate_key.py @@ -29,6 +29,18 @@ import string, random MASTER_KEY_SRC = 'master-key.txt' +def main(): + """The main body of the program.""" + + # read the master key file + key_matrix = read_key_file(open(MASTER_KEY_SRC)) + + # generate a ksv + ksv = gen_ksv() + + # generate a source key and output it + output_human_readable(ksv, gen_sink_key(ksv, key_matrix)) + def read_key_file(filelike): """Read a HDCP master key from a key file. @@ -129,11 +141,6 @@ def output_human_readable(ksv, key): print '\nKey:' print string.join(map(lambda x: string.join(x, ' '), zip(*[key_strs]*5)), '\n') -# read the master key file -key_matrix = read_key_file(open(MASTER_KEY_SRC)) - -# generate a ksv -ksv = gen_ksv() - -# generate a source key and output it -output_human_readable(ksv, gen_sink_key(ksv, key_matrix)) +# run the 'main' function if this file is being executed directly +if __name__ == '__main__': + main()