-
Notifications
You must be signed in to change notification settings - Fork 1
/
cred.py
53 lines (35 loc) · 1.09 KB
/
cred.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
from cryptography.fernet import Fernet
from datetime import datetime
import os
key = b'soYkJaGosGZ_JCHkP8A7By6AbGkSf_mWUL-wP3zUkS8='
f = Fernet(key)
email = None
psw = None
def encrypt_data(data1,data2):
email= f.encrypt(bytes(data1, 'utf-8'))
password=f.encrypt(bytes(data2,'utf-8'))
with open("data.txt","wb") as file:
file.write(email)
file.write(b'\n')
file.write(password)
def decrypt_data():
global email, psw
with open("data.txt","rb") as file:
email=file.readlines(1)
password=file.readlines(2)
x=f.decrypt(email[0])
y=f.decrypt(password[0])
email = x.decode('utf-8')
psw = y.decode('utf-8')
def re_cred():
return email, psw
""" encrypt_data()
decrypt_data() """
if not (os.path.isfile("data.txt")):
print("Before staring to use this bot please complete this process.\nIt is a one time process.")
x = str(input("Please enter email : "))
y = str(input("Please enter password : "))
encrypt_data(x,y)
decrypt_data()
else:
decrypt_data()