diff options
author | Christopher Allan Webber <cwebber@dustycloud.org> | 2011-04-03 15:31:16 -0500 |
---|---|---|
committer | Christopher Allan Webber <cwebber@dustycloud.org> | 2011-04-03 15:31:16 -0500 |
commit | c15c9843b452a1c6468f8c0d1b2f358eb31a1e10 (patch) | |
tree | 5dff701a63257c859a116288a2338c369720dce9 | |
parent | f5def6fe239f0f1b2dabfe122ca8b3b51aabb6d3 (diff) | |
download | mediagoblin-c15c9843b452a1c6468f8c0d1b2f358eb31a1e10.tar.lz mediagoblin-c15c9843b452a1c6468f8c0d1b2f358eb31a1e10.tar.xz mediagoblin-c15c9843b452a1c6468f8c0d1b2f358eb31a1e10.zip |
Added a fake_login_attempt utility.
-rw-r--r-- | mediagoblin/auth/lib.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/mediagoblin/auth/lib.py b/mediagoblin/auth/lib.py index 8de67d14..5db4982b 100644 --- a/mediagoblin/auth/lib.py +++ b/mediagoblin/auth/lib.py @@ -16,7 +16,7 @@ import os -import bcrypt +import random def bcrypt_check_password(raw_pass, stored_hash, extra_salt=None): @@ -64,3 +64,20 @@ def bcrypt_gen_password_hash(raw_pass, extra_salt=None): raw_pass = u"%s:%s" % (extra_salt, raw_pass) return unicode(bcrypt.hashpw(raw_pass, bcrypt.gensalt())) + + +def fake_login_attempt(): + """ + Pretend we're trying to login. + + Nothing actually happens here, we're just trying to take up some + time. + """ + rand_salt = bcrypt.gensalt(5) + + hashed_pass = bcrypt.hashpw(str(random.random()), rand_salt) + + randplus_stored_hash = bcrypt.hashpw(str(random.random()), rand_salt) + randplus_hashed_pass = bcrypt.hashpw(hashed_pass, rand_salt) + + randplus_stored_hash == randplus_hashed_pass |