MCPcopy
hub / github.com/django/django / get_hasher

Function get_hasher

django/contrib/auth/hashers.py:148–170  ·  view source on GitHub ↗

Return an instance of a loaded password hasher. If algorithm is 'default', return the default hasher. Lazily import hashers specified in the project's settings file if needed.

(algorithm="default")

Source from the content-addressed store, hash-verified

146
147
148def get_hasher(algorithm="default"):
149 """
150 Return an instance of a loaded password hasher.
151
152 If algorithm is 'default', return the default hasher. Lazily import hashers
153 specified in the project's settings file if needed.
154 """
155 if hasattr(algorithm, "algorithm"):
156 return algorithm
157
158 elif algorithm == "default":
159 return get_hashers()[0]
160
161 else:
162 hashers = get_hashers_by_algorithm()
163 try:
164 return hashers[algorithm]
165 except KeyError:
166 raise ValueError(
167 "Unknown password hashing algorithm '%s'. "
168 "Did you specify it in the PASSWORD_HASHERS "
169 "setting?" % algorithm
170 )
171
172
173def identify_hasher(encoded):

Calls 2

get_hashersFunction · 0.85
get_hashers_by_algorithmFunction · 0.85