def register(): form = RegisterForm(request.form) if request.method == "POST" and form.validate(): name = form.name.data username = form.username.data email = form.email.data password = sha256_crypt.encrypt(form.password.data) cursor = mysql.connection.cursor() sorgu = "SELECT * FROM users where username = %s" result = cursor.execute(sorgu, (username, )) if result > 0: flash(message="Böyle bir kullanıcı adı bulunmaktadır...", category="danger") return redirect(location=url_for("register")) else: sorgu = "INSERT into users(name,email,username,password) VALUES(%s,%s,%s,%s)" cursor.execute(sorgu, (name, email, username, password)) mysql.connection.commit() cursor.close() flash(message="Başarıyla Kayıt Oldunuz...", category="success") return redirect(location=url_for("login")) else: return render_template("register.html", form=form)
def showSignIn(): error = '' try: if request.method == "POST": name = request.form['inputName'] password = sha256_crypt.encrypt(str(request.form['inputPassword'])) c, conn = connection() data = c.execute("SELECT * FROM doctor WHERE docname = (%s)", name) data = c.fetchone()[4] if sha256_crypt.verify(password, data): session['logged_in'] = True session['username'] = name flash("You are now logged in") return redirect(url_for("main")) else: print data error = "Invalid credentials, try again." gc.collect() return render_template("signin.html", error=error) except Exception as e: # flash(e) error = "Invalid credentials, try again." return render_template("signin.html", error=error)
def change_password(token): email = confirm_token(token) user = UserInfo.query.filter(UserInfo.email == email).first_or_404() if user.password_token is not None: form = ChangePasswordForm(request.form) if form.validate_on_submit(): user = UserInfo.query.filter_by(email=email).first() if user: user.password = sha256_crypt.encrypt(str(form.password.data)) user.password_token = None subject = 'Password has been updated' html = render_template('pwchange_confirm.html', username=user.username) send_email(user.email, subject, html) db.session.commit() flash('Password successfully updated.', 'success') return redirect(url_for('login')) # else: # flash('Password change was unsuccessful.', 'danger') # return redirect(url_for('login')) else: flash('Please enter your new password.', 'success') return render_template('change_password.html', form=form) else: flash('unable to reset the password, try again.', 'danger') return redirect(url_for('login'))
def gebruikerswachtwoordaanpassen(id): cur.execute( "SELECT idUser, forename, lastname, username, idWoning, rank FROM domotica_db.User WHERE idUser=%s", (int(id)) ) gebruiker = cur.fetchall() # Vraagt het eerder gemaakte 'wachtwoordaanpassen' form aan. form = wachtwoordaanpassen() cur.execute( "SELECT idUser, forename, lastname, username, idWoning, rank FROM domotica_db.User WHERE idUser=%s", (int(id)) ) gebruiker = cur.fetchall() # Zodra de post op de pagina langs de vallidators van WTForm zijn gegaan kan de rest plaatsvinden. if form.validate_on_submit(): # Nodig voor de request die we hierna gaan maken. forminfo = wachtwoordaanpassen(request.form) # Alle velden worden binnengehaald en aan een variabele gekoppelt. wachtwoord = forminfo.password.data # Het wachtwoord wordt met een random salt gehashed en beide worden in één variabele gestopt. versleutelde_password = hash.encrypt(escape(wachtwoord)) cur.execute("UPDATE User SET password=%s WHERE idUser=%s", (versleutelde_password, int(id))) g.db_conn.commit() return redirect(url_for("admin")) return render_template("gebruiker_wachtwoord_aanpassen.html", gebruiker=gebruiker, form=form)
def setUp(self, settings_file=None, url_converters=None): super().setUp(settings_file, url_converters) # Let's add another account self.db.accounts.insert({ 'email': '[email protected]', 'password': sha256_crypt.encrypt('1234'), 'role': 'admin', 'token': 'TOKENB', 'databases': self.app.config['DATABASES'][1], 'defaultDatabase': self.app.config['DATABASES'][1], '@type': 'Account' }) self.token_b = super(TestBase, self).post('/login', { 'email': '[email protected]', 'password': '******' })[0]['token'] self.db2 = self.app.config['DATABASES'][1] # 'dht2' self.db1 = self.app.config['DATABASES'][0] # 'dht1'
def register(): form = RegisterForm(request.form) if request.method == 'POST' and form.validate(): name = form.name.data email = form.email.data username = form.username.data password = sha256_crypt.encrypt(str(form.password.data)) # Create cursor cur = mysql.connection.cursor() # Execute query cur.execute( "INSERT INTO users(name, email, username, password) VALUES(%s, %s, %s, %s)", (name, email, username, password)) # Commit to DB mysql.connection.commit() # Close connection cur.close() flash('You are now registered and can log in', 'success') return redirect(url_for('login')) return render_template('register.html', form=form)
def register(): form = RegisterForm(request.form) if request.method == 'POST' and form.validate(): name = form.name.data email = form.email.data mobile = form.mobile.data speciality = form.speciality.data username = form.username.data password = sha256_crypt.encrypt(str(form.password.data)) # create cursor cur = mysql.connection.cursor() cur.execute( "INSERT INTO users(name, email, speciality, username, password, phone_num) values(%s, %s, %s, %s, %s, %s)", (name, email, speciality, username, password, mobile)) # commit to db mysql.connection.commit() # close connection cur.close() flash('you are now registered and can log in', 'success') return redirect(url_for('index')) # continue from here return render_template('register.html', form=form)
def register(): form = RegisterForm(request.form) if request.method == "POST" and form.validate(): name = form.name.data username = form.username.data email = form.email.data password = sha256_crypt.encrypt(form.password.data) cursor = mysql.connection.cursor() query1 = "select username from users where username = %s" result = cursor.execute(query1, (username, )) if result > 0: flash( """<strong>Kapılmış!</strong> Bu kullanıcı ismi zaten alınmış. Bu sensen <a href="/login"> Giriş Yap!</a>""", "warning") return redirect(url_for("register")) query = "Insert into users(name, email, username, password) VALUES(%s, %s, %s, %s)" cursor.execute(query, (name, email, username, password)) mysql.connection.commit() cursor.close() flash("<strong>Hoşgeldin!</strong> Başarıyla kayıt oldunuz!", category="success") return redirect(url_for("login")) else: return render_template("register.html", form=form)
def gen_complete_user(name, password, mail, first_name, last_name, adress, role): """ Generiere einen User in der Datenbank mit allen einfügbaren Daten die es gibt :param name: :param password: :param mail: :param first_name: :param last_name: :param adress: :param role: :return: id des generierten Nutzers """ chars = string.ascii_letters + string.digits size = 16 salt = ''.join((random.choice(chars)) for x in range(size)) pw_hash = sha256_crypt.encrypt(password + salt) pwmd5 = get_md5_bytes(password) cursor = get_cursor() cursor.execute( 'INSERT INTO user (name, password, salt, secure_id, pw_md5, role, mail, first_name, last_name, adress) ' 'VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', [ name.lower(), pw_hash, salt, salt, pwmd5, role, mail, first_name, last_name, adress ]) return cursor.lastrowid
def post(self): sess = sessionmaker(bind=DBConnectionsFacade.get_edusson_ds())() json_data = tornado.escape.json_decode(self.request.body) username = json_data.get('username') password = json_data.get('password') boards = json_data.get('boards', []) access_level_id = json_data.get('access_level_id') is_active = json_data.get('is_active') if not password: raise MyAppException(reason='password cannot be empty', status_code=400) if not username: raise MyAppException(reason='username cannot be empty', status_code=400) user = DashUser(username=username, password=sha256_crypt.encrypt(password), is_active=is_active, access_level_id=access_level_id) for board_id in boards: board_access = DashUserBoardAccess( user=user, dashboard_id=get_analytic_dashboard(), board_id=board_id) user.boards.append(board_access) sess.add(user) sess.commit()
def register(): form = RegisterForm(request.form) if request.method == "POST" and form.validate(): name = form.name.data nickname = form.nickname.data email = form.email.data password = sha256_crypt.encrypt(form.password.data) cursor = mysql.connection.cursor() sorgu = "INSERT INTO users(name,email,nickname,password) VALUES(%s,%s,%s,%s)" cursor.execute(sorgu,(name,email,nickname,password)) mysql.connection.commit() cursor.close() flash("Başarıyla kayıt oldunuz...","success") return redirect(url_for("login")) else: return render_template("register.html",form = form)
def sample_register(): form = Sample_register(request.form) if request.method == 'POST' and form.validate() == True: username = form.username.data password = sha256_crypt.encrypt(str(form.password.data)) position = form.position.data cur = mysql.connection.cursor() # get ssnid by customer in db result = cur.execute("select * from users where position= %s", [position]) cur.close() # if the result is fetched then redirect with message as ssnid already used if result > 0: flash("Account with this position already exists,If more than 1 account is required then contact Manager",'danger') return render_template("sample_registration.html", form=form) else: cur = mysql.connection.cursor() cur.execute("insert into users(username,password,position) VALUES(%s,%s,%s)",(username,password,position)) mysql.connection.commit() cur.close() flash("Successfully User Registered",'success') return redirect('/') return render_template("sample_registration.html", form=form)
def registro(): error = '' conn = psycopg2.connect(conn_string) salida = '' try: if request.method == "POST": username = request.form['username'] email = request.form['email'] password = request.form['password'] passwordEncrypt = sha256_crypt.encrypt(password) confirm = request.form['confirm'] cursor = conn.cursor() if password == confirm: cursor.execute("INSERT into usuario (nombre, email, password) values (%s, %s, %s)", [str(username), str(email), str(passwordEncrypt)]) conn.commit() cursor.execute("SELECT nombre FROM usuario where nombre = (%s)", [request.form['username']]) for row in cursor: salida += str(row[0]) valores.usuarioActual = salida return redirect((url_for('dashboard'))) else: error = "Password does not match each other, please try again" return render_template("registro.html", error=error) except Exception as e: return render_template("registro.html", error=error)
def admin(): # Vraagt het eerder gemaakte 'NieuweGebruikerForm' form aan. form = NieuweGebruikerForm() # Zodra de post op de pagina langs de vallidators van WTForm zijn gegaan kan de rest plaatsvinden. if form.validate_on_submit(): # Nodig voor de request die we hierna gaan maken. admin = NieuweGebruikerForm(request.form) # Alle velden worden binnengehaald en aan een variabele gekoppelt. username = admin.gebruikersnaam.data password = admin.password.data voornaam = admin.voornaam.data achternaam = admin.achternaam.data rang = admin.rang.data # Een laatste check of de username wel beschikbaar is (Deze moet uniek zijn): cur.execute("SELECT username FROM User WHERE username =%s", (escape(username))) beschikbaar = cur.fetchall() if beschikbaar == (): # Het wachtwoord wordt met een random salt gehashed en beide worden in één variabele gestopt. versleutelde_password = hash.encrypt(escape(password)) # De gegevens worden naar de database verstuurd: cur.execute( "INSERT INTO User (username, forename, lastname, password, rank) VALUES (%s, %s, %s, %s, %s)", (escape(username), escape(voornaam), escape(achternaam), versleutelde_password, int(rang)), ) g.db_conn.commit() # Redirect naar dezelfde pagina voor een refresh, later misschien naar de net aangemaakte user? return redirect(url_for("admin")) return render_template("admin.html", NieuweGebruikerForm=form)
def create(user: User) -> ObjectId: try: user.password = sha256_crypt.encrypt(user.password) user_id = Base.users.insert_one(user.get_dict()).inserted_id return user_id except Exception as e: print(e) return None
def get_encrypted_password(): """ returns the user password entered in the registration form. Encrypts it using sha256 """ password = request.form["password"] encrypted_password = sha256_crypt.encrypt(password) return encrypted_password
def add_accounts_dht3and4(self): self.db.accounts.insert({ 'email': '[email protected]', 'password': sha256_crypt.encrypt('1234'), 'role': 'admin', 'token': 'TOKENC', 'databases': self.app.config['DATABASES'][2], 'defaultDatabase': self.app.config['DATABASES'][2], '@type': 'Account' }) self.token_c = super(TestBase, self).post('/login', { 'email': '[email protected]', 'password': '******' })[0]['token'] self.db.accounts.insert({ 'email': '[email protected]', 'password': sha256_crypt.encrypt('1234'), 'role': 'admin', 'token': 'TOKEND', 'databases': self.app.config['DATABASES'][3], 'defaultDatabase': self.app.config['DATABASES'][3], '@type': 'Account' }) self.token_d = super(TestBase, self).post('/login', { 'email': '[email protected]', 'password': '******' })[0]['token'] self.db3 = self.app.config['DATABASES'][2] # 'dht3' self.db4 = self.app.config['DATABASES'][3] # 'dht4'
def update_password(username): form = ChangePasswordForm(request.form) if request.method == 'POST' and form.validate(): new = form.new_password.data entered = form.old_password.data if session['prof'] == 1: cur = mysql.connection.cursor() cur.execute("SELECT password FROM admin WHERE username = %s", [username]) old = (cur.fetchone())['password'] if sha256_crypt.verify(entered, old): cur.execute( "UPDATE admin SET password = %s WHERE username = %s", (sha256_crypt.encrypt(new), username)) mysql.connection.commit() cur.close() flash('New password will be in effect from next login!!', 'info') return redirect( url_for('adminDash', username=session['username'])) cur.close() flash('Old password you entered is wrong!!, try again', 'warning') if session['prof'] == 2: cur = mysql.connection.cursor() cur.execute("SELECT password FROM member WHERE username = %s", [username]) old = (cur.fetchone())['password'] if sha256_crypt.verify(entered, old): cur.execute( "UPDATE member SET password = %s WHERE username = %s", (sha256_crypt.encrypt(new), username)) mysql.connection.commit() cur.close() flash('New password will be in effect from next login!!', 'info') return redirect( url_for('memberDash', username=session['username'])) cur.close() flash('Old password you entered is wrong!!, try again', 'warning') return render_template('updatePassword.html', form=form) return render_template('updatePassword.html', form=form)
def create_admin(mysql): cur = mysql.connection.cursor() res = cur.execute("SELECT * FROM users WHERE username=%s", ["admin"]) if res < 1: print("Creating admin account...") password = sha256_crypt.encrypt("password1") cur.execute( "INSERT INTO users(name, username, password, positionTitle, email, startDate) VALUES(%s, %s, %s, %s, %s, %s)", ("admin", "admin", password, "Admin", "*****@*****.**", "1/1/1970")) mysql.connection.commit() cur.close()
def register_user(db, form): from flask_app import Users name = form.name.data email = form.email.data username = form.username.data password = str(sha256_crypt.encrypt(form.password.data)) new_user = Users(name, email, username, password) try: db.session.add(new_user) db.session.commit() return new_user except IntegrityError: return False
def register(): form = RegistrationForm(request.form) if request.method == 'GET': return render_template('register.html', form=form) if request.method == 'POST': #if form.validate_on_submit(): fname = form.fname.data lname = form.lname.data username = form.username.data email = form.email.data password = sha256_crypt.encrypt((str(form.password.data))) createUser(fname, lname, username, email, password) return "success"
def register(): next_url = request.args.get('next') if not current_user.is_authenticated: try: if request.method == "POST": con, conn = connection() form = request.form email = form['email'] password = sha256_crypt.encrypt((str(form['password']))) used_username = con.execute( "SELECT * FROM user WHERE login = (%s)", escape_string(request.form['login'])) if "@" not in email: wrong_email = True else: wrong_email = False if used_username or wrong_email: return render_template('register.html', form=form, used_username=used_username, wrong_email=wrong_email) con.execute( "INSERT INTO scout (first_name, last_name) VALUES (%s, %s)", (escape_string( form['first-name']), escape_string(form['last-name']))) conn.commit() scout_id = con.lastrowid sql = "INSERT INTO user (login, password, email, scout_id) VALUES (%s, %s, %s, " + str( scout_id) + ")" con.execute( sql, (escape_string(form['login']), escape_string(password), escape_string(form['email']))) conn.commit() flash("Zarejestrowano pomyślnie!", 'success') send_confirmation_email(form['email']) con.close() conn.close() gc.collect() return redirect(url_for('login', next=next_url, username=email)) else: return render_template('register.html') except Exception as error: flash('Błąd: ' + str(error), 'danger') return redirect('/') else: flash("Jesteś już zalogowany!", 'warning') return redirect(next_url)
def register(): form = RegisterForm(request.form) if request.method == "POST" and form.validate(): name = form.name.data username = form.username.data email = form.email.data password = sha256_crypt.encrypt(form.password.data) cursor = mysql.connection.cursor() user_query = "Insert into users(name,username,email,password) VALUES(%s, %s, %s, %s)" cursor.execute(user_query, (name, username, email, password)) mysql.connection.commit() cursor.close() flash(message="You have successfully registered.", category="success") return redirect(url_for("login")) else: return render_template("register.html", form=form)
def index(): form = RegistrationForm(request.form) if request.method == "POST" and form.validate(): password = sha256_crypt.encrypt(form.password.data) user = User(username=form.username.data, email=form.email.data, password=password) try: db.session.add(user) db.session.commit() flash("Kaydolmayı başardın, tebrikler!","success") except: flash("Başaramadın, girdiğin bilgiler ile kayıtlı bir kullanıcı var!","info") return render_template('index.html',form = form) else: return render_template('index.html',form = form)
def save_pw(pw, id): """ Speichere übergebenes Passwort in allen benötigten Formaten in Datenbank ab :param pw: :param id: :return: None """ chars = string.ascii_letters + string.digits size = 16 salt = ''.join((random.choice(chars)) for x in range(size)) pw_hash = sha256_crypt.encrypt(pw + salt) pwmd5 = get_md5_bytes(pw) cursor = get_cursor() cursor.execute( 'UPDATE user SET password = ?, salt = ?, pw_md5 = ? WHERE secure_id = ?', [pw_hash, salt, pwmd5, id])
def gen_user(name, passwd): """ Generiere einen User in der Datenbank nur mit Name und Passwort :param name: :param passwd: :return: id des generierten nutzers """ chars = string.ascii_letters + string.digits size = 16 salt = ''.join((random.choice(chars)) for x in range(size)) pw_hash = sha256_crypt.encrypt(passwd + salt) pwmd5 = get_md5_bytes(passwd) cursor = get_cursor() cursor.execute( 'INSERT INTO user (name, password, salt, secure_id, pw_md5, role) VALUES (?, ?, ?, ?, ?, ?)', [name.lower(), pw_hash, salt, salt, pwmd5, 'user']) return cursor.lastrowid
def register(self, data): customer = session.query(UsersDbTable).filter_by(email=data['email']).first() if customer is None: bits = random.getrandbits(126) token = hex(bits) customer = UsersDbTable(name=data['name'], surname=data['surname'], email=data['email'], password=sha256_crypt.encrypt(data['password']), pseudo=data['pseudo'], type=data['type'], token=token) session.add(customer) session.commit() return customer.token else: abort(409)
def create(self, username, password, is_active, access_level_id, boards=None): user = DashUser(username=username, password=sha256_crypt.encrypt(password), is_active=is_active, access_level_id=access_level_id) if boards: self.attach_boards(user, boards) # attach board, not boards self.session.add(user) self.session.commit()
def setUp(self, settings_file=None, url_converters=None): super().setUp(settings_file, url_converters) # Let's add another account self.db.accounts.insert( { 'email': '[email protected]', 'password': sha256_crypt.encrypt('1234'), 'role': 'admin', 'token': 'FDAEWHPIOZMGU', 'databases': self.app.config['DATABASES'][1], 'defaultDatabase': self.app.config['DATABASES'][1], '@type': 'Account' } ) self.token_b = super(TestBase, self).post('/login', {'email': '[email protected]', 'password': '******'})[0]['token'] self.db2 = self.app.config['DATABASES'][1] # 'dht2' self.db1 = self.app.config['DATABASES'][0] # 'dht1'
def put(self, id): json_data = tornado.escape.json_decode(self.request.body) username = json_data.get('username') password = json_data.get('password', None) boards = json_data.get('boards', []) access_level_id = json_data.get('access_level_id', None) is_active = json_data.get('is_active', True) sess = sessionmaker(bind=DBConnectionsFacade.get_edusson_ds())() user = sess.query(DashUser).filter_by(user_id=id).first() user_board_accesses = sess.query(DashUserBoardAccess).filter_by( user_id=id, dashboard_id=get_analytic_dashboard()).all() exists_ids = [] for board_access in user_board_accesses: exists_ids.append(board_access.board_id) if board_access.board_id not in boards: sess.query(DashUserBoardAccess).filter_by( user_id=id, dashboard_id=get_analytic_dashboard(), board_id=board_access.board_id).delete() for board_id in boards: if board_id not in exists_ids: board_access = DashUserBoardAccess( user=user, dashboard_id=get_analytic_dashboard(), board_id=board_id) user.boards.append(board_access) user.username = username user.is_active = is_active if password: user.password = sha256_crypt.encrypt(password) if access_level_id: user.access_level_id = access_level_id sess.commit()
def register(): try: form = RegistrationForm(request.form) if request.method == 'POST' and form.validate(): title = form.title.data username = form.username.data email = form.email.data password = sha256_crypt.encrypt(str(form.password.data)) real_name = form.name.data db, cur = get_db() x = cur.execute('SELECT * FROM user WHERE username = ?', [username]) print(x) if x is not None and x.fetchall(): flash("That username is already taken, please choose another") return render_template('register.html', form=form) else: cur.execute( "INSERT INTO user (title, username, email, password, real_name) VALUES(?,?,?,?,?)", [title, username, email, password, real_name]) db.commit() flash("Thanks for registering!") cur.close() db.close() gc.collect() # collect garbage session['logged_in'] = True session['username'] = username return redirect(url_for('home')) return render_template('register.html', form=form) except Exception as e: return str(e)
def add_user(user): # adding address in address table result = AddressService.add_address(user['address']) if result['status'] is False: return { 'status': constants.STATUS_FAIL, 'message': 'Failed to create address' } address_id = result['address_id'] '''encrypt password''' password = sha256_crypt.encrypt(user['password']) try: log.info("adding in user table") users = RbaUser(name=user['name'], mobile=user['mobile'], email=user['email'], password=password, gender=user['gender'], aadhaar_no=user['aadhaar_no'], dob=user['dob'], profile_image=user['profile_image'], address_id=address_id) db.session.add(users) db.session.flush() op_object = { 'status': constants.STATUS_PASS, 'user_id': users.id, 'address_id': address_id } except SQLAlchemyError as e: template = "An exception of type {0} occurred. Arguments:\n{1!r}" error = template.format(type(e).__name__, e.args) log.error("problem in user table") log.error(error) op_object = {'status': constants.STATUS_FAIL, 'msg': error} return op_object
def registration_page(): try: if request.method == "POST": email = request.form['email'] password = sha256_crypt.encrypt(request.form['password']) userModel = UserModel() if userModel.get(User(email=email)): flash("User already exist", 'warning') else: userModel.create(User(email, password)) session['logged_in'] = True session['email'] = email flash("Thanks for registration :)", 'success') except Exception as e: print(e) flash("Database error", 'warning') else: return redirect(url_for('home'))
def addMember(): choices.clear() cur = mysql.connection.cursor() form = AddMemberForm(request.form) if request.method == 'POST' and form.validate(): username = form.username.data password = sha256_crypt.encrypt(str(form.password.data)) membership_no = form.membership_no.data q = cur.execute("SELECT username FROM member where membership_no = %s", [membership_no]) if q > 0: flash('Duplicate Membership No,rectify!!', 'danger') return redirect(url_for('addMember')) cur.execute( "INSERT INTO member(username, password, membership_no) VALUES(%s, %s, %s)", (username, password, membership_no)) mysql.connection.commit() cur.close() choices.clear() flash('You added a new member!!', 'success') if (session['prof'] == 1): return redirect(url_for('adminDash')) return render_template('addMember.html', form=form)
def set_password(self, password): self.password = sha256_crypt.encrypt(password)
def update(self, data): customer = session.query(UsersDbTable).filter_by(email=data['email']).first() if customer is None: abort(400) else: customer.name = customer.name if (data['name'] == '' or data['name'] == None) else data['name'] customer.surname = customer.surname if (data['surname'] == '' or data['surname'] == None) else data['surname'] customer.email = customer.email if (data['email'] == '' or data['email'] == None) else data['email'] customer.password = customer.password if (data['password'] == '' or data['password'] == None) else sha256_crypt.encrypt(data['password']) customer.pseudo = customer.pseudo if (data['pseudo'] == '' or data['pseudo'] == None) else data['pseudo'] customer.type = customer.type if (data['type'] == '' or data['type'] == None) else data['type'] session.add(customer) session.commit() return ( {'name': customer.name, 'surname': customer.surname, 'email': customer.email, 'pseudo': customer.pseudo, 'type': customer.type, 'token': customer.token, 'id': customer.id})
def hash_password(self,password): self.password_hash=sha256_crypt.encrypt(password) return self.password_hash
def set_password(self, password): hashed_password = sha256_crypt.encrypt(password) self.password = hashed_password
def encrypt_password(password: str) -> str: return sha256_crypt.encrypt(password)
def __init__(self, password, username, profile_picture, email=''): self.username = username self.password = sha256_crypt.encrypt(password) self.profile_picture = profile_picture self.email = email
def hash_password(accounts: list): for account in accounts: if "password" in account: account["password"] = sha256_crypt.encrypt(account["password"])