WALTER | Workable Algorithms for Location-aware Transmission, Encryption Response

DeterministicEncryption..::..TryEncryptAsync Method

Asynchronously tries to encrypt the given byte array.

Namespace:  Walter.Cypher
Assembly:  Walter.Cypher (in Walter.Cypher.dll)

Syntax


public Task<ValueTuple<Nullable<byte>[], Nullable<byte>[]>> TryEncryptAsync(
	byte[] clearBytes
)

Parameters

clearBytes
Type: array<Byte>[]()[][]
The clear bytes to encrypt.

Return Value

A task that represents the asynchronous operation. The task result is a tuple containing the cyphered bytes and the hash.

Exceptions


ExceptionCondition
ArgumentNullExceptionThrown if clearBytes is null.
ExceptionThrown when no ILogger is provided and an exception occurs during encryption.

Remarks


This method attempts to encrypt the provided byte array. If the encryption is successful, it computes a hash of the cipher bytes using the specified hash method. An exception is thrown if no ILogger is provided and an error occurs during encryption. This method is suitable for encrypting large amounts of data as it writes to the CryptoStream in chunks, which can help to avoid OutOfMemoryExceptions with large byte arrays.