---
title: "setWEPKey(_:flags:index:)"
framework: corewlan
role: symbol
role_heading: Instance Method
path: "corewlan/cwinterface/setwepkey(_:flags:index:)"
---

# setWEPKey(_:flags:index:)

Sets the interface WEP key.

## Declaration

```swift
func setWEPKey(_ key: Data?, flags: CWCipherKeyFlags, index: Int) throws
```

## Parameters

- `key`: An NSData object containing the WEP key.
- `flags`: An NSUInteger indicating which cipher key flags to use for the specified key.
- `index`: An NSUInteger indicating which default key index to use for the specified key.

## Discussion

Discussion key must be 5 octets for WEP-40 or 13 octets for WEP-104. If key is nil, this method clears the WEP key for the interface. index must correspond to default key index 1-4. note: In Swift, this method returns Void and is marked with the throws keyword to indicate that it throws an error in cases of failure. You call this method in a try expression and handle any errors in the catch clauses of a do statement, as described in Error Handling in The Swift Programming Language and About Imported Cocoa Error Parameters.

## See Also

### Setting interface parameters

- [setPairwiseMasterKey(_:)](corewlan/cwinterface/setpairwisemasterkey(_:).md)
- [setPower(_:)](corewlan/cwinterface/setpower(_:).md)
- [setWLANChannel(_:)](corewlan/cwinterface/setwlanchannel(_:).md)
