Reduce cost factor for hashing passwords
* Also reduce memory cost
This commit is contained in:
@@ -32,7 +32,7 @@ HASH_FUNCTION = 'sha256' # Must be in hashlib.
|
|||||||
# Linear to the hashing time. Adjust to be high but take a reasonable
|
# Linear to the hashing time. Adjust to be high but take a reasonable
|
||||||
# amount of time on your server. Measure with:
|
# amount of time on your server. Measure with:
|
||||||
# python -m timeit -s 'import passwords as p' 'p.make_hash("something")'
|
# python -m timeit -s 'import passwords as p' 'p.make_hash("something")'
|
||||||
COST_FACTOR = 29000
|
COST_FACTOR = 10000
|
||||||
|
|
||||||
|
|
||||||
def make_hash(password):
|
def make_hash(password):
|
||||||
|
@@ -72,7 +72,7 @@ def pbkdf2_bin(data, salt, iterations=1000, keylen=24, hashfunc=None):
|
|||||||
rv = u = _pseudorandom(salt + _pack_int(block))
|
rv = u = _pseudorandom(salt + _pack_int(block))
|
||||||
for i in xrange(iterations - 1):
|
for i in xrange(iterations - 1):
|
||||||
u = _pseudorandom(''.join(map(chr, u)))
|
u = _pseudorandom(''.join(map(chr, u)))
|
||||||
rv = starmap(xor, izip(rv, u))
|
rv = list(starmap(xor, izip(rv, u)))
|
||||||
buf.extend(rv)
|
buf.extend(rv)
|
||||||
return ''.join(map(chr, buf))[:keylen]
|
return ''.join(map(chr, buf))[:keylen]
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user