/// <inheritdoc /> /// <inheritdoc cref="EnsureParameter" /> public async Task ProtectAsync(byte[] userData) { this.EnsureParameter(userData); var encryptedBytes = await _encryptor.EncryptAsync(userData, _key) .ConfigureAwait(false); SetBytesToByteArray( source: encryptedBytes, target: ref userData); }
private async Task <byte[]> EncryptAsync(byte[] plainBytes, byte[] saltBytes, byte[] encryptionKey) { var salted = plainBytes.Combine(saltBytes); try { return(await _encryptor.EncryptAsync(salted, encryptionKey) .ConfigureAwait(false)); } finally { if (salted != null) { Array.Clear(salted, 0, salted.Length); } } }