Skip to content

Commit 5b72d5e

Browse files
committed
Cryptography Algorithm
1 parent 005fb0c commit 5b72d5e

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

ciphers/brute-force_caesar_cipher.py

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
message = input("Encrypted message: ")
2+
LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
3+
4+
message = message.upper()
5+
6+
for key in range(len(LETTERS)):
7+
translated = ""
8+
for symbol in message:
9+
if symbol in LETTERS:
10+
num = LETTERS.find(symbol)
11+
num = num - key
12+
if num < 0:
13+
num = num + len(LETTERS)
14+
translated = translated + LETTERS[num]
15+
else:
16+
translated = translated + symbol
17+
18+
print("Decryption using Key #%s: %s" % (key, translated))

0 commit comments

Comments
 (0)