MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / bruteforce

Function bruteforce

ciphers/rail_fence_cipher.py:87–96  ·  view source on GitHub ↗

Uses decrypt function by guessing every key >>> bruteforce("HWe olordll")[4] 'Hello World'

(input_string: str)

Source from the content-addressed store, hash-verified

85
86
87def bruteforce(input_string: str) -> dict[int, str]:
88 """Uses decrypt function by guessing every key
89
90 >>> bruteforce("HWe olordll")[4]
91 'Hello World'
92 """
93 results = {}
94 for key_guess in range(1, len(input_string)): # tries every key
95 results[key_guess] = decrypt(input_string, key_guess)
96 return results
97
98
99if __name__ == "__main__":

Callers

nothing calls this directly

Calls 1

decryptFunction · 0.70

Tested by

no test coverage detected