# digest.md5

The `digest.md5` function returns the MD5 digest of a string as lowercase hexadecimal. MD5 is not
collision resistant, so use it only where another system already expects it, such as comparing
against a compatible S3 ETag. For fingerprints you control, use
[`digest.sha256`](/functions/automation/digest.sha256).

## Usage

```python
digest.md5(data)
```

## Arguments

- **`data`**
  Required. The string to hash, as bytes.

## Returns

The digest as a 32-character lowercase hexadecimal string.

## Example

### Compare a local file with an S3 ETag

This comparison applies to single-part S3 uploads that are unencrypted or use SSE-S3.
SSE-KMS, SSE-C, and multipart uploads do not have MD5 ETags; use an explicit
[S3 checksum](https://docs.aws.amazon.com/AmazonS3/latest/userguide/checking-object-integrity.html) for those objects.

```python
local = digest.md5(fs.read_file(".build/handler.zip"))
etag = exec.run(["aws", "s3api", "head-object", "--bucket", bucket, "--key", key], output = "capture").data["ETag"].strip('"')
if local != etag:
    fail("the published object differs from the local build")
```

## Errors

- A missing argument, or an argument that is not a string, fails with an argument error.

## Related

- [`digest.sha256`](/functions/automation/digest.sha256) for fingerprints and cache keys.
- [Atmos Automation Language](/scripting/language) and the [script step](/steps/type/script)
