Skip to content

Commit

Permalink
bug fix: elimite login via url parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
usmannasir committed Jan 23, 2024
1 parent a16884b commit 1838a34
Showing 1 changed file with 20 additions and 24 deletions.
44 changes: 20 additions & 24 deletions plogical/hashPassword.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,29 @@
# import uuid

# import base64
#
# def hash_password(password):
# # uuid is used to generate a random number
# salt = uuid.uuid4().hex
# return hashlib.sha256(salt.encode() + password.encode()).hexdigest() + ':' + salt
#
#
# def check_password(hashed_password, user_password):
# password, salt = hashed_password.split(':')
# return password == hashlib.sha256(salt.encode() + user_password.encode()).hexdigest()
#
# def generateToken(serverUserName, serverPassword):
# credentials = '{0}:{1}'.format(serverUserName, serverPassword).encode()
# encoded_credentials = base64.b64encode(credentials).decode()
# return 'Basic {0}'.format(encoded_credentials)


import uuid
import bcrypt
import hashlib

def hash_password(password):
salt = bcrypt.gensalt()
hashed_password = bcrypt.hashpw(password.encode(), salt)
return hashed_password.decode()
# uuid is used to generate a random number
salt = uuid.uuid4().hex
return hashlib.sha256(salt.encode() + password.encode()).hexdigest() + ':' + salt


def check_password(hashed_password, user_password):
return bcrypt.checkpw(user_password.encode(), hashed_password.encode())
password, salt = hashed_password.split(':')
return password == hashlib.sha256(salt.encode() + user_password.encode()).hexdigest()

# def generateToken(serverUserName, serverPassword):
# credentials = '{0}:{1}'.format(serverUserName, serverPassword).encode()
# encoded_credentials = base64.b64encode(credentials).decode()
# return 'Basic {0}'.format(encoded_credentials)

# def hash_password(password):
# salt = bcrypt.gensalt()
# hashed_password = bcrypt.hashpw(password.encode(), salt)
# return hashed_password.decode()
#
# def check_password(hashed_password, user_password):
# return bcrypt.checkpw(user_password.encode(), hashed_password.encode())


def generateToken(username, password):
Expand Down

0 comments on commit 1838a34

Please sign in to comment.