Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import hashlib
- import mysql.connector
- import zipfile
- import sql
- mydb = mysql.connector.connect(host = 'localhost',
- user = 'root',
- password = 'root',
- database = 'testdb')
- mycursor = mydb.cursor()
- def hash():
- BLOCKSIZE = 65536
- hasher = hashlib.md5()
- with open('hello.txt', 'rb') as afile:
- buf = afile.read(BLOCKSIZE)
- while len(buf) > 0:
- hasher.update(buf)
- buf = afile.read(BLOCKSIZE)
- print(hasher.hexdigest())
- def login():
- print("Введите uid")
- uid=int(input())
- print("Введите пароль")
- passwd=input()
- passwd=passwd.encode('utf-8')
- hash_pass=hashlib.md5(passwd).hexdigest()
- print(hash_pass)
- find="SELECT * FROM users WHERE uid = {uid}".format(uid=uid)
- mycursor.execute(find)
- account=mycursor.fetchall()[0]
- find="SELECT name FROM users WHERE uid = {uid}".format(uid=uid)
- mycursor.execute(find)
- uid_name=mycursor.fetchall()[0][0]
- if account[-2]==hash_pass:
- print("Добро пожаловать")
- return (True, uid, uid_name)
- else:
- print('Неправильный uid или пароль')
- return (False, 0)
- def archive(uid):
- names = []
- while True:
- print("Введите id файла")
- name=input()
- s=sql.find_file_id(name)
- names.append(s)
- if name=="/close":
- break
- archname = r"C:\Users\mi\SAD\Server\archive\\"+'archive_'+str(uid)+'.zip'
- zip_file = zipfile.ZipFile(archname, 'w')
- for i in names:
- zip_file.write(i)
- zip_file.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement