PythonSqliteAndPasswordHash

From Traxel Wiki
Revision as of 16:46, 10 November 2023 by RobertBushman (talk | contribs) (Created page with "Category:Python <syntaxhighlight lang="python" line> from passlib.hash import bcrypt import sqlite3 def register(email: str, password: str): conn = sqlite.connect('test01.db') cursor = conn.cursor() cursor.execute(''' CREATE TABLE IF NOT EXISTS login ( id INTEGER PRIMARY KEY, email TEXT, hash TEXT ) ''') cursor.execute(''' INSERT INTO login (email, hash) VALUES (?, ?) ''', (username, bcrypt.hash(password)))...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
from passlib.hash import bcrypt

import sqlite3

def register(email: str, password: str):
    conn = sqlite.connect('test01.db')
    cursor = conn.cursor()
    cursor.execute('''
    CREATE TABLE IF NOT EXISTS login (
      id INTEGER PRIMARY KEY,
      email TEXT,
      hash TEXT
    )
    ''')
    cursor.execute('''
    INSERT INTO login (email, hash)
    VALUES (?, ?)
    ''', (username, bcrypt.hash(password)))
    pass