---
title: "signature(for:)"
framework: cryptokit
role: symbol
role_heading: Instance Method
path: "cryptokit/p256/signing/privatekey/signature(for:)-5h94p"
---

# signature(for:)

Generates an Elliptic Curve Digital Signature Algorithm (ECDSA) signature of the data you provide over the P-256 elliptic curve, using SHA-256 as the hash function.

## Declaration

```swift
func signature<D>(for data: D) throws -> P256.Signing.ECDSASignature where D : DataProtocol
```

## Parameters

- `data`: The data to sign.

## Return Value

Return Value The signature corresponding to the data. The signing algorithm employs randomization to generate a different signature on every call, even for the same data and key.

## See Also

### Creating a signature

- [signature(for:)](cryptokit/p256/signing/privatekey/signature(for:)-1iyzc.md)
- [P256.Signing.ECDSASignature](cryptokit/p256/signing/ecdsasignature.md)
