---
title: "init(size:)"
framework: cryptokit
role: symbol
role_heading: Initializer
path: "cryptokit/symmetrickey/init(size:)"
---

# init(size:)

Generates a new random key of the given size.

## Declaration

```swift
init(size: SymmetricKeySize)
```

## Parameters

- `size`: The size of the key to generate. You can use one of the standard sizes, like doc://com.apple.CryptoKit/documentation/CryptoKit/SymmetricKeySize/bits256, or you can create a key of custom length by initializing a doc://com.apple.CryptoKit/documentation/CryptoKit/SymmetricKeySize instance with a non-standard value.

## See Also

### Creating a key

- [init(data:)](cryptokit/symmetrickey/init(data:).md)
