---
title: "hash(data:)"
framework: cryptokit
role: symbol
role_heading: Type Method
path: "cryptokit/hashfunction/hash(data:)"
---

# hash(data:)

Computes the digest of the bytes in the given data instance and returns the computed digest.

## Declaration

```swift
static func hash<D>(data: D) -> Self.Digest where D : DataProtocol
```

## Parameters

- `data`: The data whose digest the hash function should compute. This can be any type that conforms to doc://com.apple.documentation/documentation/Foundation/DataProtocol, like doc://com.apple.documentation/documentation/Foundation/Data or an array of doc://com.apple.documentation/documentation/Swift/UInt8 instances.

## Return Value

Return Value The computed digest of the data.

## Discussion

Discussion Use this method if all your data fits into a single data instance. If the data you want to hash is too large, initialize a hash function and use the update(data:) and finalize() methods to compute the digest in blocks.
