encrypt

expect suspend fun encrypt(algorithm: Algorithm, key: SecretKey, nonce: ByteArray, messagePlaintext: ByteArray, aad: ByteArray? = null): ByteArray

Message encryption.

Return

the cipher text with the tag appended for GCM, or padded for CBC.

Parameters

key

the encryption key.

nonce

the nonce/IV.

messagePlaintext

the message to encrypt.

aad

additional authenticated data or null (not used for CBC mode).

Throws

if the given algorithm is not supported.

actual suspend fun encrypt(algorithm: Algorithm, key: SecretKey, nonce: ByteArray, messagePlaintext: ByteArray, aad: ByteArray?): ByteArray
actual suspend fun encrypt(algorithm: Algorithm, key: SecretKey, nonce: ByteArray, messagePlaintext: ByteArray, aad: ByteArray?): ByteArray

Message encryption.

Return

the cipher text with the tag appended to it (for GCM) or padded (for CBC).

Parameters

key

the encryption key.

nonce

the nonce/IV.

messagePlaintext

the message to encrypt.

aad

additional authenticated data or null (not used for CBC mode).

Throws

if the given algorithm is not supported.

actual suspend fun encrypt(algorithm: Algorithm, key: SecretKey, nonce: ByteArray, messagePlaintext: ByteArray, aad: ByteArray?): ByteArray