INNER CODE UNIT · Swift
authenticatedCipherText
jedisct1/swift-sodium · Sources/Sodium/Box.swift:84
var authenticatedCipherText = Bytes(count: message.count + MacBytes)
guard crypto_box_easy(
&authenticatedCipherText,
message,
CUnsignedLongLong(message.count),
nonce,
recipientPublicKey,
senderSecretKey
).exitCode == .SUCCESS else { return nil }
return authenticatedCipherText
}
/// Encrypts a message using public-key authenticated encryption (separated nonce)
///
/// Returns the nonce separately from the ciphertext, useful when you need to
/// store or transmit them separately.