-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathe_RobCo.py
48 lines (36 loc) · 1.08 KB
/
e_RobCo.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
# Encryption file
import random
import string
import getch
import bcrypt
import os
def encrypt_user(i):
return ''.join(
random.choice(string.ascii_letters + string.digits + string.punctuation + string.hexdigits + string.octdigits)
for _ in range(i)
)
def encoded_input(message):
print(message, end='')
ei = ""
while True:
symbol = getch.getch()
if symbol == "\n" or symbol == "\r":
break
print("*", end="", flush=True)
ei += symbol
print()
return ei
# Password
def store_password(file_path, hashed_password):
os.makedirs(os.path.dirname(file_path), exist_ok=True)
with open(file_path, 'wb') as f:
f.write(hashed_password)
def read_password(file_path):
with open(file_path, 'rb') as f:
return f.read()
def verify_password(plain_password, hashed_password):
return bcrypt.checkpw(plain_password.encode(), hashed_password)
def encrypt_password(plain_password):
salt = bcrypt.gensalt()
hashed_password = bcrypt.hashpw(plain_password.encode(), salt)
return hashed_password