-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalberti-crypt.py
More file actions
33 lines (25 loc) · 817 Bytes
/
alberti-crypt.py
File metadata and controls
33 lines (25 loc) · 817 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env python3
#Created by PepeBigotes
# This version assumes that both circles are equal
circle = "ABCDEFGHIJKLMNÑOPQRSTUVWXYZ"
# ENCRYPT #
align = input("Lettter to align with A:\n> ").upper()
if not align in circle: print("Invalid alignment"); exit(1)
align = circle.index(align)
text = input("Text to encrypt (avoid special characters):\n> ").upper()
cipher = ""
for char in text:
if char == " ":
cipher += " "
continue
try: cipher += circle[circle.index(char) + align]
except IndexError: cipher += circle[circle.index(char) + align - len(circle)]
print('\n' + cipher)
# DECRYPT #
text = ""
for char in cipher:
if char == " ":
text += " "
continue
text += circle[circle.index(char) - align]
print(text)