encrypt

@JvmName(name = "encryptAuthenticatedWithNonce")
suspend fun <K : KeyType, A : AuthCapability.Authenticated<out K>> KeyWithNonceAuthenticating<A, out K>.encrypt(    data: ByteArray,     authenticatedData: ByteArray? = null): KmmResult<SealedBox<A, NonceTrait.Required, out K>>(source)

Encrypts data using the manually specified nonce. Check yourself, before you really, really wreck yourself!

It is safe to discard the reference to nonce, as it will be added to any SealedBox.Authenticated resulting from an encryption.

Return

KmmResult.success containing a SealedBox.Authenticated if valid parameters were provided or KmmResult.failure in case of invalid parameters (e.g., key or nonce length)


@JvmName(name = "encryptWithNonce")
suspend fun <K : KeyType, A : AuthCapability<out K>> KeyWithNonce<A, out K>.encrypt(    data: ByteArray): KmmResult<SealedBox.WithNonce<A, out K>>(source)

Encrypts data using the manually specified nonce. Check yourself, before you really, really wreck yourself!

  • nonce = nonce/IV; NEVER EVER RE-USE THIS!

It is safe to discard the reference to nonce, as it will be added to any SealedBox.Authenticated resulting from an encryption.

Return

KmmResult.success containing a SealedBox.Authenticated if valid parameters were provided or KmmResult.failure in case of invalid parameters (e.g., key or nonce length)