MCPcopy
hub / github.com/django/django / encode

Method encode

django/contrib/auth/hashers.py:508–519  ·  view source on GitHub ↗
(self, password, salt)

Source from the content-addressed store, hash-verified

506 return bcrypt.gensalt(self.rounds)
507
508 def encode(self, password, salt):
509 bcrypt = self._load_library()
510 password = force_bytes(password)
511 salt = force_bytes(salt)
512 # Hash the password prior to using bcrypt to prevent password
513 # truncation as described in #20138.
514 if self.digest is not None:
515 # Use binascii.hexlify() because a hex encoded bytestring is str.
516 password = binascii.hexlify(self.digest(password).digest())
517
518 data = bcrypt.hashpw(password, salt)
519 return "%s$%s" % (self.algorithm, data.decode("ascii"))
520
521 def decode(self, encoded):
522 algorithm, empty, algostr, work_factor, data = encoded.split("$", 4)

Callers 3

verifyMethod · 0.95
harden_runtimeMethod · 0.95

Calls 3

force_bytesFunction · 0.90
_load_libraryMethod · 0.80
decodeMethod · 0.45

Tested by 1