-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcryptograhy.py
62 lines (53 loc) · 1.8 KB
/
cryptograhy.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
56
57
58
59
60
61
62
from cryptography.fernet import Fernet
import time
import pyperclip
def make_unicode(un_unicodedthing):
unicodedthing = un_unicodedthing.decode('utf-8')
return unicodedthing
key = Fernet.generate_key()
f = Fernet(key)
input1 = input("(E)ncrypt or (D)ecrypt")
if input1 == "E":
secret = input("What do you need to encrypt?")
secret = bytes(secret, 'utf-8')
input2 = input("Enter your key if any")
if input2 != "":
fernet_string = input2
f = Fernet(fernet_string)
if input2 == "":
key = key.decode('utf-8')
print("Here's your key : " + key)
print("Its pasted to your clipboard paste it somewhere")
pyperclip.copy(key)
inputnoi = input("Press Enter when you are done pasting")
secure_secret = f.encrypt(secret)
secure_secret = str(secure_secret, 'utf-8')
print("Encrypting......")
print("[O ]")
time.sleep(1)
print("[OO ]")
time.sleep(0.25)
print("[OOO ]")
time.sleep(0.25)
print("[OOOO ]")
time.sleep(0.25)
print("[OOOOO ]")
time.sleep(0.25)
print("[OOOOOO]")
print("Encryption complete , here's the encrypted string : " + str(secure_secret))
print("String copied to clipboard")
pyperclip.copy(str(secure_secret))
if input1 == "D":
secret1 = input("Copy your encrypted string to your clipboard and press Enter")
secret = pyperclip.paste()
key1 = input("Copy your key to your clipboard and press ENTER")
key = pyperclip.paste()
secret2 = bytes(secret, 'utf-8')
f = Fernet(key)
print("The decrypted string is :")
final = f.decrypt(secret2)
final2 = make_unicode(final)
print(final2)
print("String copied to clipboard")
pyperclip.copy(final2)
input1000000 = input("")