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

# Insecure.SHA1

An implementation of SHA1 hashing.

```
struct SHA1
```

## Overview

The [`Insecure.SHA1`](/documentation/CryptoKit/Insecure/SHA1) hash implements the [`HashFunction`](/documentation/CryptoKit/HashFunction) protocol to produce a
SHA1 digest ([`Insecure.SHA1Digest`](/documentation/CryptoKit/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()`](/documentation/CryptoKit/Insecure/SHA1/finalize()) method to get the
result.

> Important: This hash algorithm isn’t considered cryptographically
> secure, but is provided for backward compatibility with older services
> that require it. For new services, prefer one of the secure hashes, like
> ``doc://com.apple.CryptoKit/documentation/CryptoKit/SHA512``.

## Topics

### Specifying the output type

[`Digest`](/documentation/CryptoKit/Insecure/SHA1/Digest)

The digest type for a SHA1 hash function.

[`SHA1Digest`](/documentation/CryptoKit/Insecure/SHA1Digest)

The output of a SHA1 hash.

### Reporting the hash length

[`byteCount`](/documentation/CryptoKit/Insecure/SHA1/byteCount)

The number of bytes in a SHA1 digest.

### Computing a hash in one call

### Computing a hash iteratively

[`init()`](/documentation/CryptoKit/Insecure/SHA1/init())

Creates a SHA1 hash function.

[`update(bufferPointer:)`](/documentation/CryptoKit/Insecure/SHA1/update(bufferPointer:))

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

[`finalize()`](/documentation/CryptoKit/Insecure/SHA1/finalize())

Finalizes the hash function and returns the computed digest.

### Reporting hash function information

[`blockByteCount`](/documentation/CryptoKit/Insecure/SHA1/blockByteCount)

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

## Relationships

### Conforms To

[`Copyable`](/documentation/Swift/Copyable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Escapable`](/documentation/Swift/Escapable)

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

[`Sendable`](/documentation/Swift/Sendable)

---

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)