1

I am getting error while hashing the pain text password using Bcrypt in Python. I am providing the error below.

Traceback (most recent call last):
  File "hash.py", line 3, in <module>
    hashed = hashpw(plaintext_password, gensalt(log_rounds=13))
TypeError: gensalt() got an unexpected keyword argument 'log_rounds'

My code is given below.

from bcrypt import hashpw, gensalt
plaintext_password = 'subhra123@'
hashed = hashpw(plaintext_password, gensalt(log_rounds=13))
print hashed

Here I need to hash my password.

1
  • well looks like gensalt() does not take log_rounds as a parameter? did you look at the docs to see what exactly to pass? Commented Sep 20, 2017 at 8:59

2 Answers 2

2

Your error comes from log_rounds, you simply should just use the number. Here is an example:

hashed = hashpw(plaintext_password, gensalt(13))

From the official docs:

Adjustable Work Factor One of bcrypt’s features is an adjustable logarithmic work factor. To adjust the work factor merely pass the desired number of rounds to bcrypt.gensalt(rounds=12) which defaults to 12):

Working demo:

import bcrypt
password = b"super secret password"
# Hash a password for the first time, with a certain number of rounds
hashed = bcrypt.hashpw(password, bcrypt.gensalt(14))
# Check that a unhashed password matches one that has previously been
#   hashed
if bcrypt.hashpw(password, hashed) == hashed:
    print("It Matches!")
else:
    print("It Does not Match :(")

Here is a link to the docs, where it specifies how to work with this.

Hope this helps!

Sign up to request clarification or add additional context in comments.

Comments

2

I thing you want to use gensalt(13) or gensalt(rounds=13) instead of gensalt(log_rounds=13).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.