Mercurial > p > roundup > code
diff roundup/password.py @ 5391:a391a071d045
Python 3 preparation: use range() instead of xrange().
Tool-assisted patch. None of the existing range() uses seem to need
to be wrapped in list(). Note that range() may be less efficient than
xrange() in Python 2.
| author | Joseph Myers <jsm@polyomino.org.uk> |
|---|---|
| date | Tue, 24 Jul 2018 23:00:54 +0000 |
| parents | 35ea9b1efc14 |
| children | 3fa026621f69 |
line wrap: on
line diff
--- a/roundup/password.py Tue Jul 24 22:23:46 2018 +0000 +++ b/roundup/password.py Tue Jul 24 23:00:54 2018 +0000 @@ -33,7 +33,7 @@ _bjoin = _bempty.join def getrandbytes(count): - return _bjoin(chr(random.randint(0,255)) for i in xrange(count)) + return _bjoin(chr(random.randint(0,255)) for i in range(count)) #NOTE: PBKDF2 hash is using this variant of base64 to minimize encoding size, # and have charset that's compatible w/ unix crypt variants @@ -69,11 +69,11 @@ total_blocks = int((keylen+digest_size-1)/digest_size) hmac_template = HMAC(password, None, sha1) out = _bempty - for i in xrange(1, total_blocks+1): + for i in range(1, total_blocks+1): hmac = hmac_template.copy() hmac.update(salt + pack(">L",i)) block = tmp = hmac.digest() - for j in xrange(rounds-1): + for j in range(rounds-1): hmac = hmac_template.copy() hmac.update(tmp) tmp = hmac.digest()
