Skip to content

Commit

Permalink
Convert to .NetStandard 2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
sjh37 committed Dec 21, 2021
1 parent 7ee494d commit 0d3f4f8
Show file tree
Hide file tree
Showing 24 changed files with 1,727 additions and 2,094 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
using NUnit.Framework;

namespace Effortless.Net.Encryption.Tests.Unit
{
public class DigestTests
{
[Test]
[TestCase(HashType.MD5, "", "ED8DEEF5BA6E0731D0C01EE7C4BAFC36")]
[TestCase(HashType.SHA1, "", "D2EFCBBA102ED3339947E85F4141EB08926E40E9")]
[TestCase(HashType.SHA256, "", "A07E4F7343246C82B26F32E56F85418D518D8B2F2DAE77F1D56FE7AF50DB97AF")]
[TestCase(HashType.SHA384, "", "7428EA564921C0E1F5C927D4E72F0C4A01D9A7AC3D7A204C5A9D3040A88249953090D9763FEDA173FEE3FA71F75E27DD")]
[TestCase(HashType.SHA512, "", "2C5F15C7829564C32AF70D9AEE7389BDE5D0544534010C9058D0D7A0CC7DE49656E0674041A0907B80B1B05E18B459B5428AE8EE0F43A680F0922EE3D00E6A14")]
[TestCase(HashType.MD5, "key", "63602C271DFB9E8A2B16823A5DC5020E")]
[TestCase(HashType.SHA1, "key", "6FD75D8D3D3A7FB244F04178AA50C8AF2180BA72")]
[TestCase(HashType.SHA256, "key", "F7AAE2D999881387B8362976AD878D041527F78F7EFF7D1EAFA1A6212A2A4061")]
[TestCase(HashType.SHA384, "key", "B78E547A75A256B7902F05378D452AB6C8192D48232E312B466E40E5ED9BE1A5B77053251C5D0177EFF1DDC2A6DE9B1E")]
[TestCase(HashType.SHA512, "key", "A300C834A06AA8935B27991C2F3D044009AC1952E0B51845DD8AE2178F778C82F012C3A343266C41A493A8D16966C25A4F88E2A8FBEAE6AD8D5F0AA6FE29665A")]
public void CreateAndCreateFromString(HashType hashType, string secretKey, string hash)
{
const string data = "Hello";
var digest1 = Digest.Create(hashType, data, secretKey);
Assert.AreEqual(hash, digest1.Hash);
Assert.AreEqual(data, digest1.Data);
Assert.AreEqual(hashType, digest1.HashType);

// Check its reversable
var digest1String = digest1.ToString();
var digest2 = Digest.CreateFromString(digest1String, secretKey);
Assert.AreEqual(digest1.Data, digest2.Data);
Assert.AreEqual(digest1.Hash, digest2.Hash);
Assert.AreEqual(hashType, digest2.HashType);
}
}
using NUnit.Framework;

namespace Effortless.Net.Encryption.Tests.Unit
{
public class DigestTests
{
[Test]
[TestCase(HashType.MD5, "", "ED8DEEF5BA6E0731D0C01EE7C4BAFC36")]
[TestCase(HashType.SHA1, "", "D2EFCBBA102ED3339947E85F4141EB08926E40E9")]
[TestCase(HashType.SHA256, "", "A07E4F7343246C82B26F32E56F85418D518D8B2F2DAE77F1D56FE7AF50DB97AF")]
[TestCase(HashType.SHA384, "", "7428EA564921C0E1F5C927D4E72F0C4A01D9A7AC3D7A204C5A9D3040A88249953090D9763FEDA173FEE3FA71F75E27DD")]
[TestCase(HashType.SHA512, "", "2C5F15C7829564C32AF70D9AEE7389BDE5D0544534010C9058D0D7A0CC7DE49656E0674041A0907B80B1B05E18B459B5428AE8EE0F43A680F0922EE3D00E6A14")]
[TestCase(HashType.MD5, "key", "63602C271DFB9E8A2B16823A5DC5020E")]
[TestCase(HashType.SHA1, "key", "6FD75D8D3D3A7FB244F04178AA50C8AF2180BA72")]
[TestCase(HashType.SHA256, "key", "F7AAE2D999881387B8362976AD878D041527F78F7EFF7D1EAFA1A6212A2A4061")]
[TestCase(HashType.SHA384, "key", "B78E547A75A256B7902F05378D452AB6C8192D48232E312B466E40E5ED9BE1A5B77053251C5D0177EFF1DDC2A6DE9B1E")]
[TestCase(HashType.SHA512, "key", "A300C834A06AA8935B27991C2F3D044009AC1952E0B51845DD8AE2178F778C82F012C3A343266C41A493A8D16966C25A4F88E2A8FBEAE6AD8D5F0AA6FE29665A")]
public void CreateAndCreateFromString(HashType hashType, string secretKey, string hash)
{
const string data = "Hello";
var digest1 = Digest.Create(hashType, data, secretKey);
Assert.AreEqual(hash, digest1.Hash);
Assert.AreEqual(data, digest1.Data);
Assert.AreEqual(hashType, digest1.HashType);

// Check its reversable
var digest1String = digest1.ToString();
var digest2 = Digest.CreateFromString(digest1String, secretKey);
Assert.AreEqual(digest1.Data, digest2.Data);
Assert.AreEqual(digest1.Hash, digest2.Hash);
Assert.AreEqual(hashType, digest2.HashType);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ public class DigitalSignatureTests
{
private byte[] _hash;

[TestFixtureSetUp]
public void SetUp()
[OneTimeSetUp]
public void OneTimeSetUp()
{
_hash = Hash.Create(HashType.SHA256, "Hello world", string.Empty);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,77 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{4F6624BB-4FEE-4350-BAE9-E27BC0BB40D6}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Effortless.Net.Encryption.Test</RootNamespace>
<AssemblyName>Effortless.Net.Encryption.Test</AssemblyName>
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>3.5</OldToolsVersion>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="nunit.framework">
<HintPath>..\packages\NUnit.2.5.10.11092\lib\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="nunit.mocks">
<HintPath>..\packages\NUnit.2.5.10.11092\lib\nunit.mocks.dll</HintPath>
</Reference>
<Reference Include="pnunit.framework">
<HintPath>..\packages\NUnit.2.5.10.11092\lib\pnunit.framework.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>

<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="NUnit" Version="3.13.2" />
<PackageReference Include="NUnit3TestAdapter" Version="4.1.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Effortless.Net.Encryption.csproj">
<Project>{ECADC722-EE08-401F-BF42-368F79ED4DEF}</Project>
<Name>Effortless.Net.Encryption</Name>
</ProjectReference>
<ProjectReference Include="..\Effortless.Net.Encryption\Effortless.Net.Encryption.csproj" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

</Project>

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 0d3f4f8

Please sign in to comment.