Skip to content

Commit ab26145

Browse files
committed
Move files to separate directories
1 parent d847747 commit ab26145

11 files changed

+43
-38
lines changed

Diff for: Caesar Cipher.py

-38
This file was deleted.

Diff for: ciphers/Caesar Cipher.py

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# The Caesar Cipher Algorithm
2+
3+
def main():
4+
message = input("Enter message: ")
5+
key = int(input("Key [1-26]: "))
6+
mode = input("Encrypt or Decrypt [e/d]: ")
7+
8+
if mode.lower().startswith('e'):
9+
mode = "encrypt"
10+
elif mode.lower().startswith('d'):
11+
mode = "decrypt"
12+
13+
LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
14+
15+
translated = ""
16+
17+
message = message.upper()
18+
19+
for symbol in message:
20+
if symbol in LETTERS:
21+
num = LETTERS.find(symbol)
22+
if mode == "encrypt":
23+
num = num + key
24+
elif mode == "decrypt":
25+
num = num - key
26+
27+
if num >= len(LETTERS):
28+
num = num - len(LETTERS)
29+
elif num < 0:
30+
num = num + len(LETTERS)
31+
32+
translated = translated + LETTERS[num]
33+
else:
34+
translated = translated + symbol
35+
36+
if mode == "encrypt":
37+
print("Encryption:", translated)
38+
elif mode == "decrypt":
39+
print("Decryption:", translated)
40+
41+
42+
if __name__ == '__main__':
43+
main()
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Diff for: bubble_sort.py renamed to sorts/bubble_sort.py

File renamed without changes.
File renamed without changes.

Diff for: merge_sort.py renamed to sorts/merge_sort.py

File renamed without changes.

Diff for: quick_sort.py renamed to sorts/quick_sort.py

File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)