<!--
{
  "availability" : [

  ],
  "documentType" : "symbol",
  "framework" : "OpenSSL",
  "identifier" : "/documentation/OpenSSL/SHA256/SHA256Digest/init(rawValue:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "OpenSSL"
    ],
    "preciseIdentifier" : "s:7OpenSSL6SHA256O0C6DigestV8rawValueAE10Foundation4DataV_tKcfc"
  },
  "title" : "init(rawValue:)"
}
-->

# init(rawValue:)

Constructs a digest by adopting a caller-supplied 32-byte value.

```
init(rawValue: Data) throws
```

## Parameters

`rawValue`

The digest bytes. Must be exactly 32
bytes; any other length throws.

## Discussion

Use this when materializing a previously computed digest back
into a typed value — for example, after reading the raw bytes
from persistent storage or decoding a Nostr NIP-01 event `id`
from hex. The bytes are copied in by value (`Data` is a Swift
value type), so the initializer has no ongoing aliasing with
the caller’s buffer.

No cryptographic work is performed here — this initializer is
purely a typed wrapper around an existing digest. Compute new
digests through [`hash(data:)`](/documentation/OpenSSL/SHA256/hash(data:)) or
[`hash(string:)`](/documentation/OpenSSL/SHA256/hash(string:)).

> Throws: ``doc://OpenSSL/documentation/OpenSSL/OpenSSLError/invalidInput(_:)`` with a message
> describing the length mismatch when `rawValue.count != 32`.