Uses decrypt function by guessing every key >>> bruteforce("HWe olordll")[4] 'Hello World'
(input_string: str)
| 85 | |
| 86 | |
| 87 | def 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 | |
| 99 | if __name__ == "__main__": |