# pydoc > _sha1

---
type: CommandReference
command: _sha1
mode: pydoc
section: ""
source: pydoc3
---

## Quick Reference

- `_sha1.sha1(data=b'')` — Return a new SHA1 hash object, optionally initialized with bytes.
- `h.update(data)` — Update hash state with bytes.
- `h.digest()` — Return digest as bytes.
- `h.hexdigest()` — Return digest as hex string.
- `h.copy()` — Return a copy of the hash object.

## Name

_sha1 — SHA1 hash algorithm implementation (built-in module).

## Synopsis

python
import _sha1
h = _sha1.sha1()           # new hash object
h.update(b'data')          # feed data
digest = h.digest()        # get bytes
hexdigest = h.hexdigest()  # get hex string
## Functions

- `sha1(data=b'')` — Return a new SHA1 hash object. If `data` is given, it is equivalent to creating the object and calling `update(data)`.

## Class Methods

### `sha1`

- `copy(self)` — Return a copy of the hash object.
- `digest(self)` — Return the digest value as a bytes object.
- `hexdigest(self)` — Return the digest value as a string of hexadecimal digits.
- `update(self, obj)` — Update this hash object's state with the provided bytes.

### Data descriptors

- `block_size` — Block size of the hash algorithm.
- `digest_size` — Size of the digest in bytes.
- `name` — Name of the hash algorithm ('sha1').

## Examples

python
import _sha1

# Example 1: hash a string
h = _sha1.sha1(b'hello world')
print(h.hexdigest())  # '2ef7bde608ce5404e97d5f042f95f89f1c232871'

# Example 2: incremental update
h = _sha1.sha1()
h.update(b'hello ')
h.update(b'world')
print(h.digest().hex())  # same as above
Note: The `_sha1` module is an internal implementation; prefer `hashlib.sha1()` for portable code.