INNER CODE UNIT · Swift
decrypt
jedisct1/swift-sodium · Sources/Sodium/Aead.swift:77
func decrypt(nonceAndAuthenticatedCipherText: Bytes, secretKey: Key, additionalData: Bytes? = nil) -> Bytes? {
guard nonceAndAuthenticatedCipherText.count >= ABytes + NonceBytes else { return nil }
let nonce = nonceAndAuthenticatedCipherText[..<NonceBytes].bytes as Nonce
let authenticatedCipherText = nonceAndAuthenticatedCipherText[NonceBytes...].bytes
return decrypt(authenticatedCipherText: authenticatedCipherText, secretKey: secretKey, nonce: nonce, additionalData: additionalData)
}
/**
Decrypts a message with a shared secret key.
- Parameter authenticatedCipherText: A `Bytes` object containing authenticated ciphertext.
- Parameter secretKey: The shared secret key.
- Parameter additionalData: Must be used same `Bytes` that was used to encrypt, if `Bytes` deferred will return nil
- Returns: The decrypted message.
*/