<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CryptoKit",
  "identifier" : "/documentation/CryptoKit/HashFunction/init()",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Apple CryptoKit"
    ],
    "preciseIdentifier" : "s:9CryptoKit12HashFunctionPxycfc"
  },
  "title" : "init()"
}
-->

# init()

Creates a hash function.

```
init()
```

## Discussion

Initialize a new hash function by calling this method if you want to
hash the data iteratively, such as when you don’t have a buffer large
enough to hold all the data at once. Provide data blocks to the hash
function using the [`update(data:)`](/documentation/CryptoKit/HashFunction/update(data:)) or [`update(bufferPointer:)`](/documentation/CryptoKit/HashFunction/update(bufferPointer:))
method. After providing all the data, call [`finalize()`](/documentation/CryptoKit/HashFunction/finalize()) to get the
digest.

If your data fits into a single buffer, you can use the [`hash(data:)`](/documentation/CryptoKit/HashFunction/hash(data:))
method instead to compute the digest in a single call.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)