<!--
{
  "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/SHA512",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Apple CryptoKit"
    ],
    "preciseIdentifier" : "s:9CryptoKit6SHA512V"
  },
  "title" : "SHA512"
}
-->

# SHA512

An implementation of Secure Hashing Algorithm 2 (SHA-2) hashing with a
512-bit digest.

```
struct SHA512
```

## Overview

The [`SHA512`](/documentation/CryptoKit/SHA512) hash implements the [`HashFunction`](/documentation/CryptoKit/HashFunction) protocol for the
specific case of SHA-2 hashing with a 512-bit digest ([`SHA512Digest`](/documentation/CryptoKit/SHA512Digest)).
Larger digests take more space but are more secure.

You can compute the digest by calling the static `hash(data:)` method
once. Alternatively, if the data that you want to hash is too large to fit
in memory, you can compute the digest iteratively by creating a new hash
instance, calling the `update(data:)` method repeatedly with blocks of
data, and then calling the [`finalize()`](/documentation/CryptoKit/SHA512/finalize()) method to get the result.

## Topics

### Specifying the output type

[`SHA512.Digest`](/documentation/CryptoKit/SHA512/Digest)

The digest type for a SHA512 hash function.

[`SHA512Digest`](/documentation/CryptoKit/SHA512Digest)

The output of a Secure Hashing Algorithm 2 (SHA-2) hash with a 512-bit digest.

### Computing a hash in one call

### Computing a hash iteratively

[`init()`](/documentation/CryptoKit/SHA512/init())

Creates a SHA512 hash function.

[`update(bufferPointer:)`](/documentation/CryptoKit/SHA512/update(bufferPointer:))

Incrementally updates the hash function with the contents of the buffer.

[`finalize()`](/documentation/CryptoKit/SHA512/finalize())

Finalizes the hash function and returns the computed digest.

### Inspecting hash information

[`byteCount`](/documentation/CryptoKit/SHA512/byteCount)

The number of bytes in a SHA512 digest.

[`blockByteCount`](/documentation/CryptoKit/SHA512/blockByteCount)

The number of bytes that represents the hash function’s internal state.



---

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)