MCPcopy Create free account
hub / github.com/ActiveState/code / create_key

Function create_key

recipes/Python/456374_Crypt/recipe-456374.py:74–91  ·  view source on GitHub ↗

Generates a key. Shows the heading. Gets a destination file. Creates a key. Saves the key in the file. Flush the buffer. Closes the file. Prints confirmation.

()

Source from the content-addressed store, hash-verified

72 print 'You must enter 1, 2, 3, or 4 as a selection.'
73
74def create_key():
75 '''Generates a key.
76
77 Shows the heading.
78 Gets a destination file.
79 Creates a key.
80 Saves the key in the file.
81 Flush the buffer.
82 Closes the file.
83 Prints confirmation.'''
84 show_heading('CREATE KEY')
85 key_file = get_destination('What will be the name of the key file?')
86 key_data = create_key_data()
87 Pickler(key_file).dump(key_data)
88 key_file.flush()
89 key_file.close()
90 print 'The key has been created at the location specified.'
91 print
92
93def get_destination(prompt):
94 '''Gets destination file.

Callers 1

mainFunction · 0.85

Calls 6

show_headingFunction · 0.85
get_destinationFunction · 0.85
create_key_dataFunction · 0.85
dumpMethod · 0.45
flushMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected