ChaChaPoly
public enum ChaChaPoly : Cipher
ChaCha20-Poly1305 as described in RFC 7539 with 96-bit nonces.
-
Encrypts and seals data using ChaCha20-Poly1305.
Throws
CipherError errorsDeclaration
Swift
public static func seal<Plaintext: DataProtocol, AuthenticatedData: DataProtocol> (_ message: Plaintext, using key: SymmetricKey, nonce: Nonce? = nil, authenticating authenticatedData: AuthenticatedData) throws -> SealedBoxParameters
messageThe message to encrypt and authenticate
keyA 256-bit encryption key
nonceA nonce for ChaChaPoly encryption. The nonce must be unique for every use of the key to seal data. It can be safely generated with ChaChaPoly.Nonce()
authenticatedDataData to authenticate as part of the seal
Return Value
A sealed box returning the authentication tag (seal) and the ciphertext
-
Encrypts and seals data using ChaCha20-Poly1305.
Throws
CipherError errorsDeclaration
Swift
public static func seal<Plaintext: DataProtocol> (_ message: Plaintext, using key: SymmetricKey, nonce: Nonce? = nil) throws -> SealedBoxParameters
messageThe message to encrypt and authenticate
keyA 256-bit encryption key
nonceA nonce for ChaChaPoly encryption. The nonce must be unique for every use of the key to seal data. It can be safely generated with ChaChaPoly.Nonce()
Return Value
A sealed box returning the authentication tag (seal) and the ciphertext
-
Authenticates and decrypts data using ChaCha20-Poly1305.
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 -> DataParameters
sealedBoxThe sealed box to authenticate and decrypt
keyA 256-bit encryption key
nonceThe nonce that was provided for encryption.
authenticatedDataData that was authenticated as part of the seal
Return Value
The ciphertext if opening was successful
-
Authenticates and decrypts data using ChaCha20-Poly1305.
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 -> DataParameters
sealedBoxThe sealed box to authenticate and decrypt
keyA 256-bit encryption key
nonceThe nonce that was provided for encryption.
Return Value
The ciphertext if opening was successful
-
Undocumented
See moreDeclaration
Swift
@frozen public struct SealedBox : AEADSealedBox
-
Undocumented
See moreDeclaration
Swift
public struct Nonce : ContiguousBytes, Sequence
View on GitHub
Install in Dash
ChaChaPoly Enumeration Reference