Skip to content

Update caesar_cipher.py #3860

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 10, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 3 additions & 16 deletions ciphers/caesar_cipher.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,26 +193,13 @@ def brute_force(input_string: str, alphabet=None) -> dict:
# Set default alphabet to lower and upper case english chars
alpha = alphabet or ascii_letters

# The key during testing (will increase)
key = 1

# The encoded result
result = ""

# To store data on all the combinations
brute_force_data = {}

# Cycle through each combination
while key <= len(alpha):
# Decrypt the message
result = decrypt(input_string, key, alpha)

# Update the data
brute_force_data[key] = result

# Reset result and increase the key
result = ""
key += 1
for key in range(1, len(alpha) + 1):
# Decrypt the message and store the result in the data
brute_force_data[key] = decrypt(input_string, key, alpha)

return brute_force_data

Expand Down