MCPcopy
hub / github.com/django/django / decode

Method decode

django/contrib/auth/hashers.py:417–436  ·  view source on GitHub ↗
(self, encoded)

Source from the content-addressed store, hash-verified

415 return self.algorithm + data.decode("ascii")
416
417 def decode(self, encoded):
418 argon2 = self._load_library()
419 algorithm, rest = encoded.split("$", 1)
420 assert algorithm == self.algorithm
421 params = argon2.extract_parameters("$" + rest)
422 variety, *_, b64salt, hash = rest.split("$")
423 # Add padding.
424 b64salt += "=" * (-len(b64salt) % 4)
425 salt = base64.b64decode(b64salt, validate=True).decode("latin1")
426 return {
427 "algorithm": algorithm,
428 "hash": hash,
429 "memory_cost": params.memory_cost,
430 "parallelism": params.parallelism,
431 "salt": salt,
432 "time_cost": params.time_cost,
433 "variety": variety,
434 "version": params.version,
435 "params": params,
436 }
437
438 def verify(self, password, encoded):
439 argon2 = self._load_library()

Callers 2

safe_summaryMethod · 0.95
must_updateMethod · 0.95

Calls 3

_load_libraryMethod · 0.80
splitMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected