summaryrefslogtreecommitdiff
path: root/passlib/handlers/sha1_crypt.py
diff options
context:
space:
mode:
Diffstat (limited to 'passlib/handlers/sha1_crypt.py')
-rw-r--r--passlib/handlers/sha1_crypt.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/passlib/handlers/sha1_crypt.py b/passlib/handlers/sha1_crypt.py
index 8f9aa71..287f044 100644
--- a/passlib/handlers/sha1_crypt.py
+++ b/passlib/handlers/sha1_crypt.py
@@ -11,7 +11,6 @@ import logging; log = logging.getLogger(__name__)
# pkg
from passlib.utils import safe_crypt, test_crypt
from passlib.utils.binary import h64
-from passlib.utils.compat import u, unicode, irange
from passlib.crypto.digest import compile_hmac
import passlib.utils.handlers as uh
# local
@@ -62,7 +61,7 @@ class sha1_crypt(uh.HasManyBackends, uh.HasRounds, uh.HasSalt, uh.GenericHandler
#--GenericHandler--
name = "sha1_crypt"
setting_kwds = ("salt", "salt_size", "rounds")
- ident = u("$sha1$")
+ ident = u"$sha1$"
checksum_size = 28
checksum_chars = uh.HASH64_CHARS
@@ -126,16 +125,16 @@ class sha1_crypt(uh.HasManyBackends, uh.HasRounds, uh.HasSalt, uh.GenericHandler
return True
def _calc_checksum_builtin(self, secret):
- if isinstance(secret, unicode):
+ if isinstance(secret, str):
secret = secret.encode("utf-8")
if _BNULL in secret:
raise uh.exc.NullPasswordError(self)
rounds = self.rounds
# NOTE: this seed value is NOT the same as the config string
- result = (u("%s$sha1$%s") % (self.salt, rounds)).encode("ascii")
+ result = (u"%s$sha1$%s" % (self.salt, rounds)).encode("ascii")
# NOTE: this algorithm is essentially PBKDF1, modified to use HMAC.
keyed_hmac = compile_hmac("sha1", secret)
- for _ in irange(rounds):
+ for _ in range(rounds):
result = keyed_hmac(result)
return h64.encode_transposed_bytes(result, self._chk_offsets).decode("ascii")