mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-27 15:01:08 +00:00
Cryptography Algorithm
This commit is contained in:
parent
005fb0c5a1
commit
5b72d5e0a1
18
ciphers/brute-force_caesar_cipher.py
Normal file
18
ciphers/brute-force_caesar_cipher.py
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
message = input("Encrypted message: ")
|
||||||
|
LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||||
|
|
||||||
|
message = message.upper()
|
||||||
|
|
||||||
|
for key in range(len(LETTERS)):
|
||||||
|
translated = ""
|
||||||
|
for symbol in message:
|
||||||
|
if symbol in LETTERS:
|
||||||
|
num = LETTERS.find(symbol)
|
||||||
|
num = num - key
|
||||||
|
if num < 0:
|
||||||
|
num = num + len(LETTERS)
|
||||||
|
translated = translated + LETTERS[num]
|
||||||
|
else:
|
||||||
|
translated = translated + symbol
|
||||||
|
|
||||||
|
print("Decryption using Key #%s: %s" % (key, translated))
|
Loading…
Reference in New Issue
Block a user