From 8eec8b4b6e1933fe4775bcb14061af7425131752 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=B9i=20Nguy=E1=BB=85n=20T=E1=BA=A5n=20Sang?= Date: Tue, 13 Feb 2024 10:45:23 +0700 Subject: [PATCH] Security Patch Added md5 to the password system for added security --- account/main.py | 4 ++-- account/reliability.py | 4 ++-- database/users-account.db | Bin 12288 -> 12288 bytes 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/account/main.py b/account/main.py index ce037fd..989f553 100644 --- a/account/main.py +++ b/account/main.py @@ -2,8 +2,8 @@ import os import time import random +import hashlib import streamlit as st -from hashlib import sha256 from sendgrid import SendGridAPIClient from sendgrid.helpers.mail import Mail from account.loader import account_database_loader @@ -37,7 +37,7 @@ def send_email(subject, from_email, to_email, content): print("Error sending email:", str(e)) def add_user(email, username, password, confirm): - password = sha256(password.encode('utf-8')).hexdigest() + password = hashlib.md5(hashlib.sha256(password.encode('utf-8')).hexdigest().encode()).hexdigest() cursor.execute('''INSERT INTO users (email, username, password, confirm) VALUES (?, ?, ?, ?)''', (email, username, password, confirm)) sys_log("Created User Account", "Username: " + username + " Email: " + email) conn.commit() diff --git a/account/reliability.py b/account/reliability.py index 2f61857..903d557 100644 --- a/account/reliability.py +++ b/account/reliability.py @@ -1,7 +1,7 @@ -from hashlib import sha256 +import hashlib def get_user_reliability(cursor, username, password): - password = sha256(password.encode('utf-8')).hexdigest() + password = hashlib.md5(hashlib.sha256(password.encode('utf-8')).hexdigest().encode()).hexdigest() cursor.execute('SELECT password FROM users WHERE username = ?', (username,)) row = cursor.fetchone() diff --git a/database/users-account.db b/database/users-account.db index 0c4496d3a621cd8c7be441abe3072c521a65b698..e9a2fef73bc7c87364b89a11945ab65945dcdee2 100644 GIT binary patch delta 108 zcmZojXh@hK%{YCcj5Fi(jR_0oc^McO82R@y@bBfH%%8tmP~aoqQ