Last active
March 30, 2023 11:40
-
-
Save KarimullinArthur/75bbd88ba802fcd021b6e1757481dce4 to your computer and use it in GitHub Desktop.
Ригистрация, учусь работать с БД
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sqlite3 | |
conn = sqlite3.connect('date.db') | |
cur = conn.cursor() | |
cur.execute("""CREATE TABLE IF NOT EXISTS users( | |
id INTEGER PRIMARY KEY AUTOINCREMENT, | |
name TEXT, | |
password TEXT);""") | |
conn.commit() | |
def rigistration(): | |
global conn | |
global cur | |
login = input("Input your login\n> ") | |
check = cur.execute('SELECT * FROM users WHERE name=?', (login, )) | |
if check.fetchone() is None: | |
password = input("Input your password\n> ") | |
passwordCheck = input("Input password again\n> ") | |
if password == passwordCheck: | |
inp = (login,password) | |
cur.execute("INSERT INTO users(name,password) VALUES(?,?)",inp) | |
conn.commit() | |
print("All right, you are registered!") | |
else: | |
print("Oops,you entered two different passwords. Please try again.") | |
else: | |
print('Login busy') | |
rigistration() |
c
Я же написал, что просто учусь работать с бд, да это и было-то когда.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Password must be stored in hash (not plaintext). Hash is string that always has certain length, which is unique for each set of bits. For example passwords in (GNU/)Linux-based systems are stored in /etc/shadow in hash. For example sha1 from string
a
is3f786850e387550fdab836ed7e6dc881de23001b
, but sha1sum from stringa
(previous string with space at end) is8094deb9fe1d7d15598a8e7b876e151810630635
. I recommend to use sha512 hash function (is available in most modern Unix-like systems by default usingsha512sum
command from terminal)Sorry for my English