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

Method encode

django/contrib/auth/hashers.py:591–606  ·  view source on GitHub ↗
(self, password, salt, n=None, r=None, p=None)

Source from the content-addressed store, hash-verified

589 work_factor = 2**14
590
591 def encode(self, password, salt, n=None, r=None, p=None):
592 self._check_encode_args(password, salt)
593 n = n or self.work_factor
594 r = r or self.block_size
595 p = p or self.parallelism
596 hash_ = hashlib.scrypt(
597 password=force_bytes(password),
598 salt=force_bytes(salt),
599 n=n,
600 r=r,
601 p=p,
602 maxmem=self.maxmem,
603 dklen=64,
604 )
605 hash_ = base64.b64encode(hash_).decode("ascii").strip()
606 return "%s$%d$%s$%d$%d$%s" % (self.algorithm, n, force_str(salt), r, p, hash_)
607
608 def decode(self, encoded):
609 algorithm, work_factor, salt, block_size, parallelism, hash_ = encoded.split(

Callers 1

verifyMethod · 0.95

Calls 4

force_bytesFunction · 0.90
force_strFunction · 0.90
_check_encode_argsMethod · 0.80
decodeMethod · 0.45

Tested by

no test coverage detected