# hashlib

hashlib module - A common interface to many hash functions. new(name, data=b'', \*\*kwargs) - returns a new hash object implementing the given hash function; initializing the hash using the given binary data.

Named constructor functions are also available, these are faster than using new(name): md5(), sha1(), sha224(), sha256(), sha384(), sha512(), blake2b(), blake2s(), sha3\_224, sha3\_256, sha3\_384, sha3\_512, shake\_128, and shake\_256. More algorithms may be available on your platform but the above are guaranteed to exist. See the algorithms\_guaranteed and algorithms\_available attributes to find out what algorithm names can be passed to new(). NOTE: If you want the adler32 or crc32 hash functions they are available in the zlib module. Choose your hash function wisely. Some have known collision weaknesses. sha384 and sha512 will be slow on 32 bit platforms. Hash objects have these methods:

> * update(data): Update the hash object with the bytes in data. Repeated calls
>
>   are equivalent to a single call with the concatenation of all the arguments.
> * digest(): Return the digest of the bytes passed to the update() method
>
>   so far as a bytes object.
> * hexdigest(): Like digest() except the digest is returned as a string
>
>   of double length, containing only hexadecimal digits.
> * copy(): Return a copy (clone) of the hash object. This can be used to
>
>   efficiently compute the digests of datas that share a common initial substring.

For example, to obtain the digest of the byte string ‘Nobody inspects the spammish repetition’:

```python
import hashlib
m = hashlib.md5()
m.update(b"Nobody inspects")
m.update(b" the spammish repetition")
m.digest()
b'\xbbd\x9c\x83\xdd\x1e\xa5\xc9\xd9\xde\xc9\xa1\x8d\xf0\xff\xe9'
```

More condensed:

```python
hashlib.sha224(b"Nobody inspects the spammish repetition").hexdigest()
'a4337bc45a8fc544c03f52dc550cd6e1e87021bc896588bd79e901e2'
```

## hashlib.new(name, data=b'', \*\*kwargs)

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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.verygoodsecurity.com/vault/developer-tools/larky/library-api/hashlibs.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
