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

decrypt

@Nullable static fun decrypt(cipherText: Bytes, key: Key, nonce: Nonce): Bytes? (source)
@Nullable static fun decrypt(cipherText: Allocated, key: Key, nonce: Nonce): Allocated? (source)
@Nullable static fun decrypt(cipherText: ByteArray, key: Key, nonce: Nonce): ByteArray? (source)

Decrypt a message using a key.

Parameters

cipherText - The cipher text to decrypt.

key - The key to use for decryption.

nonce - The nonce that was used for encryption.

Return
The decrypted data, or null if verification failed.

@Nullable static fun decrypt(cipherText: Bytes, password: String): Bytes? (source)
@Nullable static fun decrypt(cipherText: ByteArray, password: String): ByteArray? (source)

Decrypt a message using 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

cipherText - The cipher text to decrypt.

password - The password that was used for encryption.

Return
The decrypted data, or null if verification failed.

@Nullable static fun decrypt(cipherText: Bytes, password: String, algorithm: Algorithm): Bytes? (source)
@Nullable static fun decrypt(cipherText: ByteArray, password: String, algorithm: Algorithm): ByteArray? (source)

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

Parameters

cipherText - The cipher text to decrypt.

password - The password that was used for encryption.

algorithm - The algorithm that was used for encryption.

Return
The decrypted data, or null if verification failed.

@Nullable static fun decrypt(cipherText: Bytes, password: String, opsLimit: Long, memLimit: Long, algorithm: Algorithm): Bytes? (source)

Decrypt a message using a password, using PasswordHash for the key generation.

Parameters

cipherText - The cipher text to decrypt.

password - The password that was used for encryption.

opsLimit - The opsLimit that was used for encryption.

memLimit - The memLimit that was used for encryption.

algorithm - The algorithm that was used for encryption.

Return
The decrypted data, or null if verification failed.

@Nullable static fun decrypt(cipherText: ByteArray, password: String, opsLimit: Long, memLimit: Long, algorithm: Algorithm): ByteArray? (source)

Decrypt a message using a password, using PasswordHash for the key generation.

Parameters

cipherText - The cipher text to decrypt.

password - The password that was used for encryption.

opsLimit - The opsLimit that was used for encryption.

memLimit - The memLimit that was used for encryption.

algorithm - The algorithm that was used for encryption.

Exceptions

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

Return
The decrypted data, or null if verification failed.