A secure container for your data that you access using a cipher.


@frozen struct SealedBox


You use a sealed box as a container for data that you want to transmit securely. You seal data into a box with one of the cipher algorithms, like seal(_:using:nonce:).

The box holds an encrypted version of the original data, an authentication tag, and the nonce during encryption. The encryption makes the data unintelligible to anyone without the key, while the authentication tag makes it possible for the intended receiver to be sure the data remains intact.

The receiver uses another instance of the same cipher to open the box, like the open(_:using:) method.


Getting the Combined Contents

let combined: Data

A combined element composed of the tag, the nonce, and the ciphertext.

Getting the Component Elements

var nonce: ChaChaPoly.Nonce

The nonce used to encrypt the data.

var ciphertext: Data

The encrypted data.

var tag: Data

An authentication tag.