Structure

SHA512

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

Declaration

struct SHA512

Overview

The SHA512 hash implements the HashFunction protocol for the specific case of SHA-2 hashing with a 512-bit digest (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() method to get the result.

Topics

Specifying the Output Type

typealias SHA512.Digest

The digest type for a SHA512 hash function.

struct SHA512Digest

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

Reporting the Hash Length

static var byteCount: Int

The number of bytes in a SHA512 digest.

Computing a Hash in One Call

static func hash<D>(data: D) -> SHA512Digest

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

Computing a Hash Iteratively

init()

Creates a SHA512 hash function.

func update<D>(data: D)

Incrementally updates the hash function with the given data.

func update(bufferPointer: UnsafeRawBufferPointer)

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

func finalize() -> SHA512.Digest

Finalizes the hash function and returns the computed digest.

See Also

Cryptographically Secure Hashes

protocol HashFunction

A type that performs cryptographically secure hashing.

Beta
struct SHA384

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

Beta
struct SHA256

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

Beta

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software