An implementation of SHA1 hashing.


struct SHA1


The Insecure.SHA1 hash implements the HashFunction protocol to produce a SHA1 digest (Insecure.SHA1Digest).

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.


Specifying the Output Type

typealias Insecure.SHA1.Digest

The digest type for a SHA1 hash function.

struct Insecure.SHA1Digest

The output of an SHA1 hash.

Reporting the Hash Length

static var byteCount: Int

The number of bytes in a SHA1 digest.

Computing a Hash in One Call

static func hash<D>(data: D) -> Insecure.SHA1Digest

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

Computing a Hash Iteratively


Creates a SHA1 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() -> Insecure.SHA1.Digest

Finalizes the hash function and returns the computed digest.

See Also


struct Insecure.MD5

An implementation of MD5 hashing.