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

Function create_key_data

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

Creates a key. Generates to lists. Creates an area for the key. Randomizes the random system. Loops 265 times doing the following: Creates two different indexs valid for list_one and list_two. Creates a tuple of two different and unique numbers. Deletes the t

()

Source from the content-addressed store, hash-verified

104 print 'Please enter a different filename.'
105
106def create_key_data():
107 '''Creates a key.
108
109 Generates to lists.
110 Creates an area for the key.
111 Randomizes the random system.
112 Loops 265 times doing the following:
113 Creates two different indexs valid for list_one and list_two.
114 Creates a tuple of two different and unique numbers.
115 Deletes the two number from the two lists.
116 Returns the key.'''
117 list_one = range(256)
118 list_two = range(256)
119 key = []
120 seed(time())
121 for index in range(256):
122 index_one = randint(0, 255 - index)
123 index_two = randint(0, 255 - index)
124 key.append((list_one[index_one], list_two[index_two]))
125 del list_one[index_one], list_two[index_two]
126 return key
127
128def encode_file():
129 '''Executes decoding subsection.

Callers 1

create_keyFunction · 0.85

Calls 3

rangeFunction · 0.85
timeFunction · 0.85
appendMethod · 0.45

Tested by

no test coverage detected