A symmetric cryptographic key.
You typically derive a symmetric key from an instance of a shared secret
(``SharedSecret``) that you obtain through key agreement. You use a
symmetric key to compute a message authentication code like ``HMAC``, or to
open and close a sealed box (``ChaChaPoly/SealedBox`` or
``AES/GCM/SealedBox``) using a cipher like ``ChaChaPoly`` or ``AES``.
func withUnsafeBytes<R>(_ body: (UnsafeRawBufferPointer) throws -> R) rethrows -> R
Calls the given closure with the contents of underlying storage.
- note: Calling `withUnsafeBytes` multiple times does not guarantee that
the same buffer pointer will be passed in every time.
- warning: The buffer argument to the body should not be stored or used
outside of the lifetime of the call to the closure.
Clients should prefer the `withBytes` function to this one, because
`withBytes` uses the non-escapable type `RawSpan` to ensure that the
buffer argument is not stored outside of the closure.
init · iOS 13.0+
init
TypeScript
static initData(data: ArrayBuffer): SymmetricKey
Swift declaration
init<D>(data: D) where D : ContiguousBytes
Creates a key from the given data.
- Parameters:
- data: The contiguous bytes from which to create the key.
Generates a new random key of the given size.
- Parameters:
- size: The size of the key to generate. You can use one of the standard
sizes, like ``SymmetricKeySize/bits256``, or you can create a key of
custom length by initializing a ``SymmetricKeySize`` instance with a
non-standard value.
get · iOS 13.0+
bitCount
TypeScript
get bitCount(): number
Swift declaration
var bitCount: Int { get }
The number of bits in the key.
Skipped declarations
4 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.
SymmetricKey.bytes
The iOS SDK compiler rejected this binding: argument type 'RawSpan' does not conform to expected type 'Escapable'
SymmetricKey.init(copying:)
The iOS SDK compiler rejected this binding: instance method 'arg' requires that 'RawSpan' conform to 'Escapable'
SymmetricKey.init(copyingWithZeroing:)
The iOS SDK compiler rejected this binding: instance method 'arg' requires that 'MutableRawSpan' conform to 'Escapable'
SymmetricKey.init(size:initializingWith:)
The iOS SDK compiler rejected this binding: expected 'copy', 'borrow', or '&' followed by an identifier or 'self' in lifetime dependence specifier