Advertisement
UNBZN
Jun 4th, 2024
28
0
Never
This is comment for paste mybank.py
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. You can add in your code a hash protection for password and a protection for SQL injection :
  2.  
  3.  
  4. Protection SQL :
  5.  
  6. # INSERT avec protection contre les injections SQL
  7. def insertData(connection, accountno, password, name, amount, phone):
  8. q = "INSERT INTO accounts(account_no, password, name, amount, phone) VALUES (%s, %s, %s, %s, %s)"
  9. values = (accountno, password, name, amount, phone)
  10. execute_query(connection, q, values)
  11.  
  12. Hash protection for password :
  13.  
  14. import bcrypt
  15.  
  16. # Hachage du mot de passe
  17. def hash_password(password):
  18. salt = bcrypt.gensalt()
  19. return bcrypt.hashpw(password.encode('utf-8'), salt)
  20.  
  21. # Dans la fonction signup, remplacez la ligne d'insertion par :
  22. hashed_password = hash_password(password)
  23. insertData(connection, accountno, hashed_password, name, amount, phone)
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement