Skip to content

Commit

Permalink
Removed unused parameter 'username' from _hash
Browse files Browse the repository at this point in the history
  • Loading branch information
ebracho committed Aug 16, 2015
1 parent d287e4f commit 6bd0827
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions blogwig/blogwig.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def login(request):
raise HTTPException(400, 'username or password missing')
cur = db.execute('SELECT id, password, salt FROM users WHERE username = ?', (username,))
user = next(cur)
hashed = _hash(username, password, user['salt'])
hashed = _hash(password, user['salt'])
if hmac.compare_digest(user['password'], hashed):
response = Response(code=303, location='/admin')
response.set_secure_cookie(request, 'user_id', str(user['id']), max_age=LOGIN_TIME)
Expand Down Expand Up @@ -124,11 +124,11 @@ def init_db():

def create_user(username, password):
salt = os.urandom(16)
hashed = _hash(username, password, salt)
hashed = _hash(password, salt)
db.execute('INSERT INTO users (username, password, salt) VALUES(?, ?, ?)',
(username, hashed, salt))

def _hash(username, password, salt):
def _hash(password, salt):
dk = hashlib.pbkdf2_hmac('sha256', password.encode('utf-8'), salt, 100000)
return binascii.hexlify(dk)

Expand Down

0 comments on commit 6bd0827

Please sign in to comment.