Added example program
This commit is contained in:
parent
063a50fdbe
commit
46060ff451
|
@ -1,10 +1,12 @@
|
||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio Version 17
|
# Visual Studio Version 17
|
||||||
VisualStudioVersion = 17.14.36212.18 d17.14
|
VisualStudioVersion = 17.14.36212.18
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EonaCat.Crypto", "EonaCat.Crypto\EonaCat.Crypto.csproj", "{E08BA387-7F8B-4BCA-81CA-039173FF1DA9}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EonaCat.Crypto", "EonaCat.Crypto\EonaCat.Crypto.csproj", "{E08BA387-7F8B-4BCA-81CA-039173FF1DA9}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Example", "Example\Example.csproj", "{D4D451EE-157B-4BCD-92B1-617CF709A35F}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
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}.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.ActiveCfg = Release|Any CPU
|
||||||
{E08BA387-7F8B-4BCA-81CA-039173FF1DA9}.Release|Any CPU.Build.0 = 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
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|
|
@ -1,10 +1,32 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Library</OutputType>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFrameworks>net48;net8.0</TargetFrameworks>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<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>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="..\icon.png">
|
||||||
|
<Pack>True</Pack>
|
||||||
|
<PackagePath>\</PackagePath>
|
||||||
|
</None>
|
||||||
|
<None Include="..\README.md">
|
||||||
|
<Pack>True</Pack>
|
||||||
|
<PackagePath>\</PackagePath>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -181,7 +181,7 @@ namespace EonaCat.Crypto
|
||||||
byte[] input = new byte[previous.Length + info.Length + 1];
|
byte[] input = new byte[previous.Length + info.Length + 1];
|
||||||
Buffer.BlockCopy(previous, 0, input, 0, previous.Length);
|
Buffer.BlockCopy(previous, 0, input, 0, previous.Length);
|
||||||
Buffer.BlockCopy(info, 0, input, previous.Length, info.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);
|
previous = hmacExpand.ComputeHash(input);
|
||||||
roundKeys[i] = new byte[_blockSize];
|
roundKeys[i] = new byte[_blockSize];
|
||||||
|
@ -218,7 +218,7 @@ namespace EonaCat.Crypto
|
||||||
using var hmacExpand = new HMACSHA512Custom(prk);
|
using var hmacExpand = new HMACSHA512Custom(prk);
|
||||||
byte[] input = new byte[info.Length + 1];
|
byte[] input = new byte[info.Length + 1];
|
||||||
Buffer.BlockCopy(info, 0, input, 0, info.Length);
|
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);
|
byte[] okm = hmacExpand.ComputeHash(input);
|
||||||
|
|
||||||
|
|
|
@ -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>
|
|
@ -10,7 +10,7 @@ class Program
|
||||||
byte[] key = new byte[128];
|
byte[] key = new byte[128];
|
||||||
RandomNumberGeneratorCustom.ComputeHash(key);
|
RandomNumberGeneratorCustom.ComputeHash(key);
|
||||||
|
|
||||||
var crypto = new EonaCatCrypto("WERKT DIT GEWOON?");
|
var crypto = new EonaCatCrypto("WERKT DIT GEWOON?");
|
||||||
//var crypto = new EonaCatCrypto(key);
|
//var crypto = new EonaCatCrypto(key);
|
||||||
|
|
||||||
string longLoremIpsum = @"
|
string longLoremIpsum = @"
|
||||||
|
@ -71,6 +71,8 @@ End of test string.
|
||||||
if (!File.Exists(inputFilePath))
|
if (!File.Exists(inputFilePath))
|
||||||
{
|
{
|
||||||
inputFilePath = "EonaCat.Crypto.SampleFile.txt";
|
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
|
// Create a sample file if it doesn't exist
|
||||||
File.WriteAllText(inputFilePath, longLoremIpsum);
|
File.WriteAllText(inputFilePath, longLoremIpsum);
|
||||||
Console.WriteLine($"Sample file created: {inputFilePath}");
|
Console.WriteLine($"Sample file created: {inputFilePath}");
|
Loading…
Reference in New Issue