Skip to content

Commit be378a6

Browse files
committed
Update keyword_cipher.py
1 parent c4e1fb2 commit be378a6

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

scripts/python/encryption/keyword_cipher.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
from rich import print
22
from string import ascii_uppercase
33

4-
# Note: This is still in progress!
5-
64

75
def main() -> None:
6+
print(create_cipher_map("COLLEGE"))
7+
88
print(encrypt("A B C D E F G H I J K L M N O P Q R S T U V W X Y Z", "KRYPTOS"))
9+
print(encrypt("UNIVERSITY", "COLLEGE")) # UMFVGRSFTY
910
print(encrypt("Knowledge is Power", "KRYPTOS")) # IlmWjbaEb GQ NmWbp
1011
print(encrypt("zljeft dtOT", "secret")) # ZOMBIE HERE
1112

@@ -23,11 +24,11 @@ def encrypt(plain_text: str, keyword: str) -> str:
2324

2425

2526
def create_cipher_map(keyword: str) -> str:
26-
output = str(set(keyword.upper()))
27-
for char in ascii_uppercase:
28-
if not char in keyword:
29-
output += char
30-
return output
27+
cipher_map = []
28+
for char in (keyword.upper() + ascii_uppercase):
29+
if not char in cipher_map:
30+
cipher_map.append(char)
31+
return cipher_map
3132

3233

3334
if __name__ == "__main__":

0 commit comments

Comments
 (0)