Added example program

This commit is contained in:
EonaCat 2025-07-05 22:10:42 +02:00
parent 063a50fdbe
commit 46060ff451
5 changed files with 50 additions and 6 deletions

View File

@ -1,10 +1,12 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.14.36212.18 d17.14
VisualStudioVersion = 17.14.36212.18
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EonaCat.Crypto", "EonaCat.Crypto\EonaCat.Crypto.csproj", "{E08BA387-7F8B-4BCA-81CA-039173FF1DA9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Example", "Example\Example.csproj", "{D4D451EE-157B-4BCD-92B1-617CF709A35F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -15,6 +17,10 @@ Global
{E08BA387-7F8B-4BCA-81CA-039173FF1DA9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E08BA387-7F8B-4BCA-81CA-039173FF1DA9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E08BA387-7F8B-4BCA-81CA-039173FF1DA9}.Release|Any CPU.Build.0 = Release|Any CPU
{D4D451EE-157B-4BCD-92B1-617CF709A35F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D4D451EE-157B-4BCD-92B1-617CF709A35F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D4D451EE-157B-4BCD-92B1-617CF709A35F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D4D451EE-157B-4BCD-92B1-617CF709A35F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -1,10 +1,32 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<OutputType>Library</OutputType>
<TargetFrameworks>net48;net8.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Title>EonaCat.Crypto</Title>
<Authors>EonaCat (Jeroen Saey)</Authors>
<Company>EonaCat (Jeroen Saey)</Company>
<Description>EonaCat Crypto</Description>
<Copyright>EonaCat (Jeroen Saey)</Copyright>
<PackageProjectUrl>https://www.nuget.org/packages/EonaCat.Crypto/</PackageProjectUrl>
<PackageIcon>icon.png</PackageIcon>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageTags>EonaCat, Crypto, Security, Hashing, Password, Secure, Jeroen, Saey</PackageTags>
</PropertyGroup>
<ItemGroup>
<None Include="..\icon.png">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
<None Include="..\README.md">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>
</Project>

View File

@ -181,7 +181,7 @@ namespace EonaCat.Crypto
byte[] input = new byte[previous.Length + info.Length + 1];
Buffer.BlockCopy(previous, 0, input, 0, previous.Length);
Buffer.BlockCopy(info, 0, input, previous.Length, info.Length);
input[^1] = (byte)(i + 1);
input[input.Length -1] = (byte)(i + 1);
previous = hmacExpand.ComputeHash(input);
roundKeys[i] = new byte[_blockSize];
@ -218,7 +218,7 @@ namespace EonaCat.Crypto
using var hmacExpand = new HMACSHA512Custom(prk);
byte[] input = new byte[info.Length + 1];
Buffer.BlockCopy(info, 0, input, 0, info.Length);
input[^1] = 1; // Counter byte
input[input.Length - 1] = 1; // Counter byte
byte[] okm = hmacExpand.ComputeHash(input);

14
Example/Example.csproj Normal file
View File

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\EonaCat.Crypto\EonaCat.Crypto.csproj" />
</ItemGroup>
</Project>

View File

@ -10,7 +10,7 @@ class Program
byte[] key = new byte[128];
RandomNumberGeneratorCustom.ComputeHash(key);
var crypto = new EonaCatCrypto("WERKT DIT GEWOON?");
var crypto = new EonaCatCrypto("WERKT DIT GEWOON?");
//var crypto = new EonaCatCrypto(key);
string longLoremIpsum = @"
@ -71,6 +71,8 @@ End of test string.
if (!File.Exists(inputFilePath))
{
inputFilePath = "EonaCat.Crypto.SampleFile.txt";
encryptedFilePath = "EonaCat.Crypto.SampleFile.dat";
decryptedFilePath = "EonaCat.Crypto.SampleFile_decrypted.txt";
// Create a sample file if it doesn't exist
File.WriteAllText(inputFilePath, longLoremIpsum);
Console.WriteLine($"Sample file created: {inputFilePath}");