crypto / org.apache.tuweni.crypto.sodium / SecretBox / encryptDetached

encryptDetached

static fun encryptDetached(message: Bytes, key: Key, nonce: Nonce): DetachedEncryptionResult (source)
static fun encryptDetached(message: ByteArray, key: Key, nonce: Nonce): DetachedEncryptionResult (source)

Encrypt a message with a key, generating a detached message authentication code.

Parameters

message - The message to encrypt.

key - The key to use for encryption.

nonce - A unique nonce.

Return
The encrypted data and message authentication code.

static fun encryptDetached(message: Bytes, password: String): DetachedEncryptionResult (source)
static fun encryptDetached(message: ByteArray, password: String): DetachedEncryptionResult (source)

Encrypt a message with a password, generating a detached message authentication code, using PasswordHash for the key generation (with the currently recommended algorithm and limits on operations and memory that are suitable for most use-cases).

Parameters

message - The message to encrypt.

password - The password to use for encryption.

Return
The encrypted data and message authentication code.

static fun encryptDetached(message: Bytes, password: String, algorithm: Algorithm): DetachedEncryptionResult (source)
static fun encryptDetached(message: ByteArray, password: String, algorithm: Algorithm): DetachedEncryptionResult (source)

Encrypt a message with a password, generating a detached message authentication code, using PasswordHash for the key generation (with limits on operations and memory that are suitable for most use-cases).

Parameters

message - The message to encrypt.

password - The password to use for encryption.

algorithm - The algorithm to use.

Return
The encrypted data and message authentication code.

static fun encryptDetached(message: Bytes, password: String, opsLimit: Long, memLimit: Long, algorithm: Algorithm): DetachedEncryptionResult (source)

Encrypt a message with a password, generating a detached message authentication code, using PasswordHash for the key generation

Parameters

message - The message to encrypt.

password - The password to use for encryption.

opsLimit - The operations limit, which must be in the range PasswordHash#minOpsLimit() to PasswordHash#maxOpsLimit().

memLimit - The memory limit, which must be in the range PasswordHash#minMemLimit() to PasswordHash#maxMemLimit().

algorithm - The algorithm to use.

Return
The encrypted data and message authentication code.

static fun encryptDetached(message: ByteArray, password: String, opsLimit: Long, memLimit: Long, algorithm: Algorithm): DetachedEncryptionResult (source)

Encrypt a message with a password, generating a detached message authentication code, using PasswordHash for the key generation.

Parameters

message - The message to encrypt.

password - The password to use for encryption.

opsLimit - The operations limit, which must be in the range PasswordHash#minOpsLimit() to PasswordHash#maxOpsLimit().

memLimit - The memory limit, which must be in the range PasswordHash#minMemLimit() to PasswordHash#maxMemLimit().

algorithm - The algorithm to use.

Return
The encrypted data and message authentication code.