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
algorithm
must be one of Algorithm.A128GCM, Algorithm.A192GCM, Algorithm.A256GCM, Algorithm.A128CBC, Algorithm.A192CBC, Algorithm.A256CBC.
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
Message encryption.
Return
the cipher text with the tag appended to it (for GCM) or padded (for CBC).
Parameters
algorithm
must be one of Algorithm.A128GCM, Algorithm.A192GCM, Algorithm.A256GCM, Algorithm.A128CBC, Algorithm.A192CBC, Algorithm.A256CBC.
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.