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

# update(data:)

Incrementally updates the hash function with the given data.

## Declaration

```swift
mutating func update<D>(data: D) where D : DataProtocol
```

## Parameters

- `data`: The next block of data for the ongoing digest calculation. You can provide this as 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.

## Discussion

Discussion Call this method one or more times to provide data to the hash function in blocks. After providing the last block of data, call the finalize() method to get the computed digest. Don’t call the update method again after finalizing the hash function.

## See Also

### Computing a hash iteratively

- [init()](cryptokit/hashfunction/init().md)
- [update(bufferPointer:)](cryptokit/hashfunction/update(bufferpointer:).md)
- [finalize()](cryptokit/hashfunction/finalize().md)
