Initial Commit (not working)
commit
7193cd0df9
|
@ -0,0 +1,40 @@
|
||||||
|
# Autosave files
|
||||||
|
*~
|
||||||
|
|
||||||
|
# build
|
||||||
|
[Oo]bj/
|
||||||
|
[Bb]in/
|
||||||
|
packages/
|
||||||
|
TestResults/
|
||||||
|
|
||||||
|
# globs
|
||||||
|
Makefile.in
|
||||||
|
*.DS_Store
|
||||||
|
*.sln.cache
|
||||||
|
*.suo
|
||||||
|
*.cache
|
||||||
|
*.pidb
|
||||||
|
*.userprefs
|
||||||
|
*.usertasks
|
||||||
|
config.log
|
||||||
|
config.make
|
||||||
|
config.status
|
||||||
|
aclocal.m4
|
||||||
|
install-sh
|
||||||
|
autom4te.cache/
|
||||||
|
*.user
|
||||||
|
*.tar.gz
|
||||||
|
tarballs/
|
||||||
|
test-results/
|
||||||
|
Thumbs.db
|
||||||
|
|
||||||
|
# Mac bundle stuff
|
||||||
|
*.dmg
|
||||||
|
*.app
|
||||||
|
|
||||||
|
# resharper
|
||||||
|
*_Resharper.*
|
||||||
|
*.Resharper
|
||||||
|
|
||||||
|
# dotCover
|
||||||
|
*.dotCover
|
|
@ -0,0 +1,15 @@
|
||||||
|
using System;
|
||||||
|
using System.Text;
|
||||||
|
namespace sharp.hashing
|
||||||
|
{
|
||||||
|
public abstract class HashBase : IHash {
|
||||||
|
|
||||||
|
UTF8Encoding utf8 = new UTF8Encoding();
|
||||||
|
|
||||||
|
public abstract byte[] compute(byte[] data);
|
||||||
|
public byte[] compute(string data)
|
||||||
|
{
|
||||||
|
return compute(utf8.GetBytes(data));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
using System;
|
||||||
|
namespace sharp.hashing
|
||||||
|
{
|
||||||
|
public interface IHash
|
||||||
|
{
|
||||||
|
byte[] compute(byte[] data);
|
||||||
|
byte[] compute(string data);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
|
// Information about this assembly is defined by the following attributes.
|
||||||
|
// Change them to the values specific to your project.
|
||||||
|
|
||||||
|
[assembly: AssemblyTitle("sharp.hashing")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("")]
|
||||||
|
[assembly: AssemblyCopyright("")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
|
||||||
|
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
|
||||||
|
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
|
||||||
|
|
||||||
|
[assembly: AssemblyVersion("1.0.*")]
|
||||||
|
|
||||||
|
// The following attributes are used to specify the signing key for the assembly,
|
||||||
|
// if desired. See the Mono documentation for more information about signing.
|
||||||
|
|
||||||
|
//[assembly: AssemblyDelaySign(false)]
|
||||||
|
//[assembly: AssemblyKeyFile("")]
|
|
@ -0,0 +1,99 @@
|
||||||
|
using System;
|
||||||
|
using System.Threading;
|
||||||
|
namespace sharp.hashing.SHA3
|
||||||
|
{
|
||||||
|
public class Keccak : HashBase
|
||||||
|
{
|
||||||
|
struct keccak_1600_std {
|
||||||
|
public readonly int output_size;
|
||||||
|
public readonly int r, c;
|
||||||
|
|
||||||
|
public keccak_1600_std(int output_size,int r,int c){
|
||||||
|
this.output_size = output_size;
|
||||||
|
this.r = r;
|
||||||
|
this.c = c;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
keccak_1600_std[] std1600 = {
|
||||||
|
new keccak_1600_std(224,1152,448),
|
||||||
|
new keccak_1600_std(256,1088,512),
|
||||||
|
new keccak_1600_std(384,832,768),
|
||||||
|
new keccak_1600_std(512,576,1024)
|
||||||
|
};
|
||||||
|
|
||||||
|
private int output_size,r, c;
|
||||||
|
|
||||||
|
|
||||||
|
public Keccak(int size)
|
||||||
|
{
|
||||||
|
foreach (keccak_1600_std std in std1600){
|
||||||
|
if (std.output_size == size){
|
||||||
|
this.r = std.r;
|
||||||
|
this.c = std.c;
|
||||||
|
this.output_size = std.output_size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.output_size != size){
|
||||||
|
throw new ArgumentException("No Standard Parameters for that Output Size defined!");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public override byte[] compute(byte[] data)
|
||||||
|
{
|
||||||
|
byte[] result = null;
|
||||||
|
|
||||||
|
Monitor.Enter(this);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Monitor.Exit(this);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private UInt64[] RC = {
|
||||||
|
0x0000000000000001,
|
||||||
|
0x0000000000008082,
|
||||||
|
0x800000000000808A,
|
||||||
|
0x8000000080008000,
|
||||||
|
0x000000000000808B,
|
||||||
|
0x0000000080000001,
|
||||||
|
0x8000000080008081,
|
||||||
|
0x8000000000008009,
|
||||||
|
0x000000000000008A,
|
||||||
|
0x0000000000000088,
|
||||||
|
0x0000000080008009,
|
||||||
|
0x000000008000000A,
|
||||||
|
0x000000008000808B,
|
||||||
|
0x800000000000008B,
|
||||||
|
0x8000000000008089,
|
||||||
|
0x8000000000008003,
|
||||||
|
0x8000000000008002,
|
||||||
|
0x8000000000000080,
|
||||||
|
0x000000000000800A,
|
||||||
|
0x800000008000000A,
|
||||||
|
0x8000000080008081,
|
||||||
|
0x8000000000008080,
|
||||||
|
0x0000000080000001,
|
||||||
|
0x8000000080008008
|
||||||
|
};
|
||||||
|
|
||||||
|
// RO[y][x]
|
||||||
|
private int[][] RO = {
|
||||||
|
new int[]{03,10,43,25,39},
|
||||||
|
new int[]{36,44,06,55,20},
|
||||||
|
new int[]{00,01,62,28,27},
|
||||||
|
new int[]{18,02,61,56,14},
|
||||||
|
new int[]{41,45,15,21,08}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{CCD7C196-B079-4AA7-98AF-5BECAD089CE4}</ProjectGuid>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<RootNamespace>sharp.hashing</RootNamespace>
|
||||||
|
<AssemblyName>sharp.hashing</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<ConsolePause>false</ConsolePause>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release</OutputPath>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<ConsolePause>false</ConsolePause>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="IHash.cs" />
|
||||||
|
<Compile Include="HashBase.cs" />
|
||||||
|
<Compile Include="SHA3\Keccak.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="SHA3\" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
|
</Project>
|
Loading…
Reference in New Issue