MCPcopy Create free account
hub / github.com/asweigart/PythonStdioGames / generateRandomKey

Function generateRandomKey

src/gamesbyexample/affinecipher.py:132–138  ·  view source on GitHub ↗

Generate and return a random encryption key.

()

Source from the content-addressed store, hash-verified

130
131
132def generateRandomKey():
133 """Generate and return a random encryption key."""
134 while True:
135 keyA = random.randint(2, len(SYMBOLS))
136 keyB = random.randint(2, len(SYMBOLS))
137 if gcd(keyA, len(SYMBOLS)) == 1:
138 return keyA * len(SYMBOLS) + keyB
139
140
141def gcd(a, b):

Callers 1

mainFunction · 0.70

Calls 1

gcdFunction · 0.85

Tested by

no test coverage detected