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

encrypt

static fun encrypt(message: Bytes!, key: Key!, nonce: Nonce!): Bytes! (source)

Encrypt a message with a key.

Parameters

message - Bytes!: The message to encrypt.

key - Key!: The key to use for encryption.

nonce - Nonce!: A unique nonce.

Return
Bytes!: The encrypted data.

static fun encrypt(message: Allocated!, key: Key!, nonce: Nonce!): Allocated! (source)

Encrypt a message with a key.

Parameters

message - Allocated!: The message to encrypt.

key - Key!: The key to use for encryption.

nonce - Nonce!: A unique nonce.

Return
Allocated!: The encrypted data.

static fun encrypt(message: ByteArray!, key: Key!, nonce: Nonce!): ByteArray! (source)

Encrypt a message with a key.

Parameters

message - ByteArray!: The message to encrypt.

key - Key!: The key to use for encryption.

nonce - Nonce!: A unique nonce.

Return
ByteArray!: The encrypted data.

static fun encrypt(message: Bytes!, password: String!): Bytes! (source)

Encrypt a message with a password, 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 - Bytes!: The message to encrypt.

password - String!: The password to use for encryption.

Return
Bytes!: The encrypted data.

static fun encrypt(message: ByteArray!, password: String!): ByteArray! (source)

Encrypt a message with a password, 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 - ByteArray!: The message to encrypt.

password - String!: The password to use for encryption.

Return
ByteArray!: The encrypted data.

static fun encrypt(message: Bytes!, password: String!, algorithm: Algorithm!): Bytes! (source)

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

Parameters

message - Bytes!: The message to encrypt.

password - String!: The password to use for encryption.

algorithm - Algorithm!: The algorithm to use.

Return
Bytes!: The encrypted data.

static fun encrypt(message: ByteArray!, password: String!, algorithm: Algorithm!): ByteArray! (source)

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

Parameters

message - ByteArray!: The message to encrypt.

password - String!: The password to use for encryption.

algorithm - Algorithm!: The algorithm to use.

Return
ByteArray!: The encrypted data.

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

Encrypt a message with a password, using PasswordHash for the key generation.

Parameters

message - Bytes!: The message to encrypt.

password - String!: The password to use for encryption.

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

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

algorithm - Algorithm!: The algorithm to use.

Return
Bytes!: The encrypted data.

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

Encrypt a message with a password, using PasswordHash for the key generation.

Parameters

message - ByteArray!: The message to encrypt.

password - String!: The password to use for encryption.

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

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

algorithm - Algorithm!: The algorithm to use.

Exceptions

UnsupportedOperationException - If the specified algorithm is not supported by the currently loaded sodium native library.

Return
ByteArray!: The encrypted data.