MCPcopy Index your code
hub / github.com/python/cpython / __hash_new

Function __hash_new

Lib/hashlib.py:170–186  ·  view source on GitHub ↗

new(name, data=b'') - Return a new hashing object using the named algorithm; optionally initialized with data (which must be a bytes-like object).

(name, *args, **kwargs)

Source from the content-addressed store, hash-verified

168
169
170def __hash_new(name, *args, **kwargs):
171 """new(name, data=b'') - Return a new hashing object using the named algorithm;
172 optionally initialized with data (which must be a bytes-like object).
173 """
174 if name in __block_openssl_constructor:
175 # __block_openssl_constructor is expected to contain strings only
176 assert isinstance(name, str), f"unexpected name: {name}"
177 # Prefer our builtin blake2 implementation.
178 return __get_builtin_constructor(name)(*args, **kwargs)
179 try:
180 return _hashlib.new(name, *args, **kwargs)
181 except ValueError:
182 # If the _hashlib module (OpenSSL) doesn't support the named
183 # hash, try using our builtin implementations.
184 # This allows for SHA224/256 and SHA384/512 support even though
185 # the OpenSSL library prior to 0.9.8 doesn't provide them.
186 return __get_builtin_constructor(name)(*args, **kwargs)
187
188
189try:

Callers

nothing calls this directly

Calls 2

newMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…