-
Notifications
You must be signed in to change notification settings - Fork 2
/
encryption.py
66 lines (52 loc) · 1.43 KB
/
encryption.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
63
64
65
66
'''
Night_Fury v2.0
AdarshRazor
10.10.2020 06:30AM
'''
from cryptography.fernet import Fernet
from tkinter import filedialog
import tkinter as tk
import os
def encryption_message(message,key,path="./output"):
print(message)
en_message=message.encode()
k=Fernet(key)
encrypted_message=k.encrypt(en_message)
os.system('cls')
print("Message is encrypted !!")
print("1. Print message")
print("2. Export file")
option_encryption_message=int(input("\nEnter option :"))
if(option_encryption_message==1):
print("\n",encrypted_message)
elif(option_encryption_message==2):
print("Exporting file and secret key")
os.chdir(path)
data_file = open("data.file", "wb")
data_file.write(encrypted_message)
data_file.close()
export_key()
exit()
else:
breakpoint
def encrypting_file(message,key,path):
k=Fernet(key)
encrypted_message=k.encrypt(message)
os.system('cls')
path="./output"
print("Message is encrypted !! Check the ouput folder")
print("Exporting file and secret key")
os.chdir(path)
data_file = open("data.file", "wb")
data_file.write(encrypted_message)
data_file.close()
export_key()
def export_key():
key_file=open("secret.key", "wb")
key_file.write(key)
key_file.close()
def export_keys(key):
return(key)
########### main program
key=Fernet.generate_key()
export_keys(key)