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)
| 168 | |
| 169 | |
| 170 | def __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 | |
| 189 | try: |
nothing calls this directly
no test coverage detected
searching dependent graphs…