python - werkzeug.security.check_password_hash takes too long -


check_password_hash taking longer expected. tested werkzeug 0.12 , 0.9. test below shows checking password taking 2 seconds. why take long?

the project uses gae -google app engine. , deployed on gae. not sure if gae has werkzeug libraries overwrite 1 have installed. use gae sdk version 1.9.50

def verify_password(self, password):     logging.info(self.password_hash)     logging.info(str(datetime.now()))     result = check_password_hash(self.password_hash, password)     logging.info(str(datetime.now()))     return result 
hash:pbkdf2:sha256:...................................... 2017-07-28 13:52:14.904270 2017-07-28 13:52:17.041060 

================= edit 1 ============ ok, seems haven't cleared libraries folder completely. have tried multiple times , upgrading werkzeug==0.9.6 werkzeug==0.12 solves problem. downgrading 0.9.6 returns problem back.

that fixed problem on machine. on gae server delay still there. ================= edit 2 ============ after creating minimalistic project, tested again , on gae behavior same. saw in database there 2 types of passwords: 1 sha1 , other sha256. sha1 working fast on gae well.

at beginning thought problem because of difference between sha1 , sha256. real problem comes number of iterations used when password created. http://werkzeug.pocoo.org/docs/0.12/utils/#werkzeug.security.generate_password_hash

using makes password decoding fast again.

generate_password_hash(password, method='pbkdf2:sha256:200') 

in database had passwords both types because have upgraded library run time.

pbkdf2:sha1:1000$....... pbkdf2:sha256:50000$...... 

so difference between first , second 1 huge because of 1000 vs 50000 iterations.


Comments

Popular posts from this blog

javascript - Create a stacked percentage column -

Optimising Firebase database by automatically overwriting data -

javascript - Angular UI-Grid customTemplate directive causing rows to load slowly/? -