-
Encrypts and authenticates data using AES-GCM.
Throws
CipherError errorsDeclaration
Swift
public static func seal<Plaintext: DataProtocol, AuthenticatedData: DataProtocol> (_ message: Plaintext, using key: SymmetricKey, nonce: Nonce? = nil, authenticating authenticatedData: AuthenticatedData) throws -> SealedBox
Parameters
message
The message to encrypt and authenticate
key
An encryption key of 128, 192 or 256 bits
nonce
An Nonce for AES-GCM encryption. The nonce must be unique for every use of the key to seal data. It can be safely generated with AES.GCM.Nonce()
authenticatedData
Data to authenticate as part of the seal
Return Value
A sealed box returning the authentication tag (seal) and the ciphertext
-
Encrypts and authenticates data using AES-GCM.
Throws
CipherError errorsDeclaration
Swift
public static func seal<Plaintext: DataProtocol> (_ message: Plaintext, using key: SymmetricKey, nonce: Nonce? = nil) throws -> SealedBox
Parameters
message
The message to encrypt and authenticate
key
An encryption key of 128, 192 or 256 bits
nonce
An Nonce for AES-GCM encryption. The nonce must be unique for every use of the key to seal data. It can be safely generated with AES.GCM.Nonce()
Return Value
A sealed box returning the authentication tag (seal) and the ciphertext
-
Authenticates and decrypts data using AES-GCM.
Throws
CipherError errors. If the authentication of the sealedbox failed, incorrectTag is thrown.Declaration
Swift
public static func open<AuthenticatedData: DataProtocol> (_ sealedBox: SealedBox, using key: SymmetricKey, authenticating authenticatedData: AuthenticatedData) throws -> Data
Parameters
sealedBox
The sealed box to authenticate and decrypt
key
An encryption key of 128, 192 or 256 bits
nonce
An Nonce for AES-GCM encryption. The nonce must be unique for every use of the key to seal data. It can be safely generated with AES.GCM.Nonce().
authenticatedData
Data that was authenticated as part of the seal
Return Value
The ciphertext if opening was successful
-
Authenticates and decrypts data using AES-GCM.
Throws
CipherError errors. If the authentication of the sealedbox failed, incorrectTag is thrown.Declaration
Swift
public static func open(_ sealedBox: SealedBox, using key: SymmetricKey) throws -> Data
Parameters
sealedBox
The sealed box to authenticate and decrypt
key
An encryption key of 128, 192 or 256 bits
nonce
An Nonce for AES-GCM encryption. The nonce must be unique for every use of the key to seal data. It can be safely generated with AES.GCM.Nonce().
Return Value
The ciphertext if opening was successful
-
Undocumented
See moreDeclaration
Swift
public struct SealedBox : AEADSealedBox
-
Undocumented
See moreDeclaration
Swift
public struct Nonce : ContiguousBytes, Sequence