-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcrytFun.py
More file actions
52 lines (26 loc) · 808 Bytes
/
crytFun.py
File metadata and controls
52 lines (26 loc) · 808 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
34
35
import random
import string
class wordCryt:
#vars
chars = " " + string.punctuation + string.digits + string.ascii_letters
chars = list(chars)
key = chars.copy()
random.shuffle(key)
#ERCRYPT
def encryt():
input_plain_txt = input("Enter message to encrypt: ")
cipher_txt = ""
for letter in input_plain_txt:
i = wordCryt.chars.index(letter)
cipher_txt += wordCryt.key[i]
encryt()
#DECRYPT
def decryt():
input_cipher_txt = input("Enter message to decryt: ")
decryt_plain_txt = ""
for letter in input_cipher_txt:
i = wordCryt.key.index(letter)
decryt_plain_txt += wordCryt.chars[i]
print(f"encrypted message: {decryt_plain_txt}")
print(f"this is orginal message decryted: {input_cipher_txt}")
decryt()