repl.it
Python

No description

fork
loading
Files
  • main.py
main.py
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import replit
import random
import time
key = ''
alphabet = ['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', '@', '#', '$', '&']
path = input("Do you want to encrypt a message or decrypt a message? \n")
if path == 'encrypt':
	#print(path[:4])
	message = input("Enter your message. \n")
	origin = message
	limit = len(message)
	for i in range(limit):
		pick = random.choice(alphabet)
		if pick in message:
			print("false")
		else:
			message = message.replace(message[i], pick)
			alphabet.remove(pick)
			time.sleep(0.06)
			replit.clear()
			print(message)
	for i in range(limit):
		c1 = origin[i]
		c2 = message[i]
		c3 = c1 + c2
		if c3 in key:
			print("false")
		else:
			key = key + c3
			time.sleep(0.06)
			replit.clear()
			print("Encrypted message - " + message)
			print("KEY - " + key)
			print("Note: please ignore the spam falses if you receive them.")
elif path == 'decrypt':
	pad = []
	code = input("Enter the encrypted message. \n")
	cracker = input("Enter the key. \n")
	limit2 = len(cracker)
	limit3 = len(code)
	i = 0
	o = 0
	truemessage = ''
	for i in range(limit3):
		examine = code[i]
		o = 0
		while o <= limit2 - 2:
			truevalue = cracker[o]
			falsevalue = cracker[o + 1]
			if falsevalue in examine:
				truemessage = truemessage + examine.replace(falsevalue, truevalue)
				time.sleep(0.06)
				replit.clear()
				print("Decrypted message - " + truemessage)
			o = o + 2
?