Skip to content

Commit 022f014

Browse files
committed
Update test project to net5.0
1 parent 30de353 commit 022f014

File tree

2 files changed

+21
-18
lines changed

2 files changed

+21
-18
lines changed

src/EntityFrameworkCore.DataEncryption/Providers/AesProvider.cs

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,15 @@ namespace Microsoft.EntityFrameworkCore.DataEncryption.Providers
1010
/// </summary>
1111
public class AesProvider : IEncryptionProvider
1212
{
13-
private const int AesBlockSize = 128;
14-
private const int InitializationVectorSize = 16;
13+
/// <summary>
14+
/// AES block size constant.
15+
/// </summary>
16+
public const int AesBlockSize = 128;
17+
18+
/// <summary>
19+
/// Initialization vector size constant.
20+
/// </summary>
21+
public const int InitializationVectorSize = 16;
1522

1623
private readonly byte[] _key;
1724
private readonly CipherMode _mode;
@@ -59,20 +66,16 @@ public string Encrypt(string dataToEncrypt)
5966

6067
byte[] initializationVector = cryptoServiceProvider.IV;
6168

62-
using (ICryptoTransform encryptor = cryptoServiceProvider.CreateEncryptor(_key, initializationVector))
69+
using ICryptoTransform encryptor = cryptoServiceProvider.CreateEncryptor(_key, initializationVector);
70+
using var memoryStream = new MemoryStream();
71+
using (var cryptoStream = new CryptoStream(memoryStream, encryptor, CryptoStreamMode.Write))
6372
{
64-
using (var memoryStream = new MemoryStream())
65-
{
66-
using (var cryptoStream = new CryptoStream(memoryStream, encryptor, CryptoStreamMode.Write))
67-
{
68-
memoryStream.Write(initializationVector, 0, initializationVector.Length);
69-
cryptoStream.Write(input, 0, input.Length);
70-
cryptoStream.FlushFinalBlock();
71-
}
72-
73-
encrypted = memoryStream.ToArray();
74-
}
73+
memoryStream.Write(initializationVector, 0, initializationVector.Length);
74+
cryptoStream.Write(input, 0, input.Length);
75+
cryptoStream.FlushFinalBlock();
7576
}
77+
78+
encrypted = memoryStream.ToArray();
7679
}
7780

7881
return Convert.ToBase64String(encrypted);

test/EntityFrameworkCore.DataEncryption.Test/EntityFrameworkCore.DataEncryption.Test.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp3.0</TargetFramework>
4+
<TargetFramework>net5.0</TargetFramework>
55
<IsPackable>false</IsPackable>
66
<AssemblyName>Microsoft.EntityFrameworkCore.Encryption.Test</AssemblyName>
77
<RootNamespace>Microsoft.EntityFrameworkCore.Encryption.Test</RootNamespace>
@@ -12,9 +12,9 @@
1212
<PrivateAssets>all</PrivateAssets>
1313
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
1414
</PackageReference>
15-
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.0" />
16-
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.0" />
17-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
15+
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.1" />
16+
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.1" />
17+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
1818
<PackageReference Include="xunit" Version="2.4.1" />
1919
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
2020
<PrivateAssets>all</PrivateAssets>

0 commit comments

Comments
 (0)