├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── SharpHash.PerformanceBenchmark ├── PerformanceBenchmark.cs ├── Program.cs └── SharpHash.PerformanceBenchmark.csproj ├── SharpHash.Tests ├── Base │ ├── Blake2BPTestVectors.cs │ ├── Blake2BTestVectors.cs │ ├── Blake2SPTestVectors.cs │ ├── Blake2STestVectors.cs │ ├── Blake3TestVectors.cs │ ├── BlakeBaseTests.cs │ ├── CShakeBaseTests.cs │ ├── CryptoHashBaseTests.cs │ ├── HashAdapter1BaseTests.cs │ ├── HashAdapter2BaseTests.cs │ ├── HashBaseTests.cs │ ├── HashWithUInt32AsKeyBaseTests.cs │ ├── HashWithUInt64AsKeyBaseTests.cs │ ├── KMACBaseTests.cs │ ├── ShakeBaseTests.cs │ ├── TestAddons.cs │ └── XOFBaseTests.cs ├── Checksum │ ├── Adler32Tests.cs │ └── CRCTests.cs ├── CreateHashTests.cs ├── Crypto │ ├── Blake2BPTests.cs │ ├── Blake2BTests.cs │ ├── Blake2SPTests.cs │ ├── Blake2STests.cs │ ├── Blake3Tests.cs │ ├── GOST3411_2012_256Tests.cs │ ├── GOST3411_2012_512Tests.cs │ ├── GostTests.cs │ ├── Grindahl256Tests.cs │ ├── Grindahl512Tests.cs │ ├── HAS160Tests.cs │ ├── HavalTests.cs │ ├── Keccak_224Tests.cs │ ├── Keccak_256Tests.cs │ ├── Keccak_288Tests.cs │ ├── Keccak_384Tests.cs │ ├── Keccak_512Tests.cs │ ├── MD2Tests.cs │ ├── MD4Tests.cs │ ├── MD5Tests.cs │ ├── PanamaTests.cs │ ├── RIPEMD128Tests.cs │ ├── RIPEMD160Tests.cs │ ├── RIPEMD256Tests.cs │ ├── RIPEMD320Tests.cs │ ├── RIPEMDTests.cs │ ├── RadioGatun32Tests.cs │ ├── RadioGatun64Tests.cs │ ├── SHA0Tests.cs │ ├── SHA1Tests.cs │ ├── SHA2_224Tests.cs │ ├── SHA2_256Tests.cs │ ├── SHA2_384Tests.cs │ ├── SHA2_512Tests.cs │ ├── SHA2_512_224Tests.cs │ ├── SHA2_512_256Tests.cs │ ├── SHA3_224Tests.cs │ ├── SHA3_256Tests.cs │ ├── SHA3_384Tests.cs │ ├── SHA3_512Tests.cs │ ├── Snefru_8_128Tests.cs │ ├── Snefru_8_256Tests.cs │ ├── Tiger2Tests.cs │ ├── TigerTests.cs │ └── WhirlPoolTests.cs ├── Hash128 │ ├── MurmurHash3_x64_128Tests.cs │ ├── MurmurHash3_x86_128Tests.cs │ └── SipHash128_2_4Tests.cs ├── Hash32 │ ├── APTests.cs │ ├── BKDRTests.cs │ ├── Bernstein1Tests.cs │ ├── BernsteinTests.cs │ ├── DEKTests.cs │ ├── DJBTests.cs │ ├── ELFTests.cs │ ├── FNV1aTests.cs │ ├── FNVTests.cs │ ├── JSTests.cs │ ├── Jenkins3Tests.cs │ ├── Murmur2Tests.cs │ ├── MurmurHash3_x86_32Tests.cs │ ├── OneAtTimeTests.cs │ ├── PJWTests.cs │ ├── RSTests.cs │ ├── RotatingTests.cs │ ├── SDBMTests.cs │ ├── ShiftAndXorTests.cs │ ├── SuperFastTests.cs │ └── XXHash32Tests.cs ├── Hash64 │ ├── FNV1a64Tests.cs │ ├── FNV64Tests.cs │ ├── Murmur2_64Tests.cs │ ├── SipHash64_2_4Tests.cs │ └── XXHash64Tests.cs ├── HashSpecialTests.cs ├── KDF │ ├── PBKDF2_HMACTests.cs │ ├── PBKDF_Argon2Tests.cs │ ├── PBKDF_Blake3Tests.cs │ └── PBKDF_ScryptTests.cs ├── NullDigestTests.cs ├── SharpHash.Tests.csproj ├── XOFandKMAC │ ├── Blake2BMACTests.cs │ ├── Blake2SMACTests.cs │ ├── Blake2XBTests.cs │ ├── Blake2XSTests.cs │ ├── Blake3XOFTests.cs │ ├── CShake_128Tests.cs │ ├── CShake_256Tests.cs │ ├── KMAC128Tests.cs │ ├── KMAC256Tests.cs │ ├── Shake_128Tests.cs │ └── Shake_256Tests.cs └── default_data.txt └── SharpHash ├── Base ├── HMACNotBuildInAdapter.cs ├── Hash.cs ├── HashBuffer.cs ├── HashCryptoNotBuildIn.cs ├── HashFactory.cs ├── HashResult.cs ├── HashRounds.cs ├── HashSize.cs └── MultipleTransformNonBlock.cs ├── Checksum ├── Adler32.cs ├── CRC.cs ├── CRC16.cs ├── CRC32.cs ├── CRC32Fast.cs └── CRC64.cs ├── Crypto ├── Blake2B.cs ├── Blake2BConfigurations │ ├── Blake2BConfig.cs │ ├── Blake2BIvBuilder.cs │ ├── Blake2BTreeConfig.cs │ └── Blake2XBConfig.cs ├── Blake2BP.cs ├── Blake2S.cs ├── Blake2SConfigurations │ ├── Blake2SConfig.cs │ ├── Blake2SIvBuilder.cs │ ├── Blake2STreeConfig.cs │ └── Blake2XSConfig.cs ├── Blake2SP.cs ├── Blake3.cs ├── GOST3411_2012.cs ├── Gost.cs ├── Grindahl256.cs ├── Grindahl512.cs ├── HAS160.cs ├── Haval.cs ├── MD2.cs ├── MD4.cs ├── MD5.cs ├── MDBase.cs ├── Panama.cs ├── RIPEMD.cs ├── RIPEMD128.cs ├── RIPEMD160.cs ├── RIPEMD256.cs ├── RIPEMD320.cs ├── RadioGatun32.cs ├── RadioGatun64.cs ├── SHA0.cs ├── SHA1.cs ├── SHA2_224.cs ├── SHA2_256.cs ├── SHA2_256Base.cs ├── SHA2_384.cs ├── SHA2_512.cs ├── SHA2_512Base.cs ├── SHA2_512_224.cs ├── SHA2_512_256.cs ├── SHA3.cs ├── Snefru.cs ├── Tiger.cs ├── Tiger2.cs └── WhirlPool.cs ├── Hash128 ├── MurmurHash3_x64_128.cs ├── MurmurHash3_x86_128.cs └── SipHash128.cs ├── Hash32 ├── AP.cs ├── BKDR.cs ├── Bernstein.cs ├── Bernstein1.cs ├── DEK.cs ├── DJB.cs ├── ELF.cs ├── FNV.cs ├── FNV1a.cs ├── JS.cs ├── Jenkins3.cs ├── Murmur2.cs ├── MurmurHash3_x86_32.cs ├── OneAtTime.cs ├── PJW.cs ├── RS.cs ├── Rotating.cs ├── SDBM.cs ├── ShiftAndXor.cs ├── SuperFast.cs └── XXHash32.cs ├── Hash64 ├── FNV1a64.cs ├── FNV64.cs ├── Murmur2_64.cs ├── SipHash64.cs └── XXHash64.cs ├── Interfaces ├── IBlake2BConfigurations │ ├── IBlake2BConfig.cs │ ├── IBlake2BTreeConfig.cs │ └── IBlake2XBConfig.cs ├── IBlake2SConfigurations │ ├── IBlake2SConfig.cs │ ├── IBlake2STreeConfig.cs │ └── IBlake2XSConfig.cs ├── ICRC.cs ├── IHash.cs ├── IHashInfo.cs ├── IHashResult.cs └── IKDF.cs ├── KDF ├── Argon2TypeAndVersion.cs ├── KDFNotBuiltIn.cs ├── PBKDF2_HMACNotBuildInAdapter.cs ├── PBKDF_Argon2NotBuildInAdapter.cs ├── PBKDF_Blake3NotBuiltInAdapter.cs └── PBKDF_ScryptNotBuildInAdapter.cs ├── NullDigest └── NullDigest.cs ├── SharpHash.csproj ├── SharpHash.sln └── Utils ├── ArrayUtils.cs ├── Bits.cs ├── Converters.cs ├── ExtendedBitConverter.cs ├── HashLibTypes.cs ├── LangBuilder.cs └── Utils.cs /.travis.yml: -------------------------------------------------------------------------------- 1 | language: csharp 2 | solution: "./SharpHash/SharpHash.sln" 3 | matrix: 4 | include: 5 | - os: windows 6 | - os: linux 7 | dist: trusty 8 | dotnet: 2.0.0 9 | - os: osx 10 | osx_image: xcode11.2 11 | dotnet: 2.0.0 12 | 13 | branches: 14 | only: 15 | - master 16 | 17 | mono: none 18 | 19 | env: 20 | global: 21 | - DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 22 | - DOTNET_CLI_TELEMETRY_OPTOUT=1 23 | 24 | before_install: 25 | - if [ "$TRAVIS_OS_NAME" = "windows" ]; then choco install vcbuildtools && PowerShell -Command 'Install-WindowsFeature Net-Framework-Core' ; fi 26 | 27 | script: 28 | - cd SharpHash.Tests 29 | - dotnet restore 30 | - dotnet build 31 | - dotnet test 32 | -------------------------------------------------------------------------------- /SharpHash.PerformanceBenchmark/Program.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using System; 28 | using System.Collections.Generic; 29 | 30 | namespace SharpHash.PerformanceBenchmark 31 | { 32 | internal class Program 33 | { 34 | private static void Main(string[] args) 35 | { 36 | List stringList = new List(); 37 | 38 | Console.WriteLine("Please be patient, this might take some time \n\r"); 39 | 40 | try 41 | { 42 | PerformanceBenchmark.DoBenchmark(ref stringList); 43 | 44 | foreach (var log in stringList) 45 | Console.WriteLine(log); 46 | 47 | Console.WriteLine("\n\rPerformance Benchmark Finished"); 48 | 49 | Console.ReadLine(); 50 | } 51 | catch (Exception e) 52 | { 53 | Console.WriteLine($"{e.ToString()} : {e.Message}"); 54 | } 55 | } 56 | } 57 | } -------------------------------------------------------------------------------- /SharpHash.PerformanceBenchmark/SharpHash.PerformanceBenchmark.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | netcoreapp2.2 6 | 7 | 8 | 9 | x64 10 | true 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /SharpHash.Tests/Base/HashAdapter1BaseTests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Tests; 29 | 30 | namespace SharpHash 31 | { 32 | [TestClass] 33 | public abstract class HashAdapter1BaseTests : HashBaseTests 34 | { 35 | protected string ExpectedHashOfOnetoNine { get; set; } 36 | protected string ExpectedHashOfabcde { get; set; } 37 | 38 | [TestMethod] 39 | public void TestOnetoNine() 40 | { 41 | TestHelper.TestActualAndExpectedData(TestConstants.OnetoNine, 42 | ExpectedHashOfOnetoNine, hash); 43 | } 44 | 45 | [TestMethod] 46 | public void TestBytesabcde() 47 | { 48 | TestHelper.TestActualAndExpectedData(TestConstants.Bytesabcde, 49 | ExpectedHashOfabcde, hash); 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Base/HashAdapter2BaseTests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Tests; 29 | 30 | namespace SharpHash 31 | { 32 | [TestClass] 33 | public abstract class HashAdapter2BaseTests : HashBaseTests 34 | { 35 | protected string ExpectedHashOfRandomString { get; set; } 36 | protected string ExpectedHashOfZerotoFour { get; set; } 37 | protected string ExpectedHashOfEmptyDataWithOneAsKey { get; set; } 38 | 39 | [TestMethod] 40 | public void TestRandomString() 41 | { 42 | TestHelper.TestActualAndExpectedData(TestConstants.RandomStringTobacco, 43 | ExpectedHashOfRandomString, hash); 44 | } 45 | 46 | [TestMethod] 47 | public void TestZerotoFour() 48 | { 49 | TestHelper.TestActualAndExpectedData(TestConstants.ZerotoFour, 50 | ExpectedHashOfZerotoFour, hash); 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Base/KMACBaseTests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | namespace SharpHash 28 | { 29 | public class KMACBaseTests : XOFBaseTests 30 | { 31 | protected readonly string RawKeyInHex = "404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F"; 32 | protected readonly string CustomizationMessage = "My Tagged Application"; 33 | protected string Data; 34 | } 35 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Base/XOFBaseTests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using SharpHash.Interfaces; 28 | using SharpHash.Tests; 29 | using System; 30 | 31 | namespace SharpHash 32 | { 33 | public class XOFBaseTests 34 | { 35 | protected static unsafe void CallShouldRaiseException(IXOF XofInstance) 36 | { 37 | byte[] Output = new byte[XofInstance.XOFSizeInBits >> 3]; 38 | 39 | fixed (byte* bPtr = TestConstants.Bytesabcde) 40 | { 41 | IntPtr abcdePtr = (IntPtr)bPtr; 42 | 43 | XofInstance.Initialize(); 44 | XofInstance.TransformUntyped(abcdePtr, TestConstants.Bytesabcde.Length); 45 | XofInstance.DoOutput(ref Output, 0, (UInt64)Output.Length); 46 | // this call below should raise exception since we have already read from the Xof 47 | XofInstance.TransformUntyped(abcdePtr, TestConstants.Bytesabcde.Length); 48 | } // 49 | } // 50 | } 51 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Checksum/Adler32Tests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Checksum.Tests 31 | { 32 | [TestClass] 33 | public class Adler32Tests : HashAdapter1BaseTests 34 | { 35 | public Adler32Tests() 36 | { 37 | hash = HashFactory.Checksum.CreateAdler32(); 38 | 39 | ExpectedHashOfEmptyData = "00000001"; 40 | ExpectedHashOfDefaultData = "25D40524"; 41 | ExpectedHashOfOnetoNine = "091E01DE"; 42 | ExpectedHashOfabcde = "05C801F0"; 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Crypto/Blake3Tests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Crypto.Tests 31 | { 32 | [TestClass] 33 | public class Blake3Tests : CryptoHashBaseTests 34 | { 35 | public Blake3Tests() 36 | { 37 | hash = HashFactory.Crypto.CreateBlake3_256(null); 38 | 39 | ExpectedHashOfEmptyData = "AF1349B9F5F9A1A6A0404DEA36DCC9499BCB25C9ADC112B7CC9A93CAE41F3262"; 40 | ExpectedHashOfDefaultData = "BB8DB7E4155BFDB254AD49D8D3105C57B6AC3E783E6D316A75E8B8F8911EB41F"; 41 | ExpectedHashOfOnetoNine = "B7D65B48420D1033CB2595293263B6F72EABEE20D55E699D0DF1973B3C9DEED1"; 42 | ExpectedHashOfabcde = "0648C03B5AD9BB6DDF8306EEF6A33EBAE8F89CB4741150C1AE9CD662FDCC1EE2"; 43 | ExpectedHashOfDefaultDataWithHMACWithLongKey = "A7F72F6A236F4572079427B0FD44516705B3322FB3A8D85ACFCB759804529E96"; 44 | ExpectedHashOfDefaultDataWithHMACWithShortKey = "D4DE3C2DE89625AF7076FEC6CFD7B0D318665514D1F88CF68F567AC4971B6681"; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Crypto/GOST3411_2012_256Tests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | using SharpHash.Tests; 30 | 31 | namespace SharpHash.Crypto.Tests 32 | { 33 | [TestClass] 34 | public class GOST3411_2012_256Tests : HashBaseTests 35 | { 36 | private string ExpectedHashOfQuickBrownFox { get; set; } 37 | 38 | public GOST3411_2012_256Tests() 39 | { 40 | hash = HashFactory.Crypto.CreateGOST3411_2012_256(); 41 | 42 | ExpectedHashOfEmptyData = "3F539A213E97C802CC229D474C6AA32A825A360B2A933A949FD925208D9CE1BB"; 43 | ExpectedHashOfQuickBrownFox = "3E7DEA7F2384B6C5A3D0E24AAA29C05E89DDD762145030EC22C71A6DB8B2C1F4"; 44 | } 45 | 46 | [TestMethod] 47 | public new void TestDefaultData() // For QuickBrownFox 48 | { 49 | TestHelper.TestActualAndExpectedData(TestConstants.QuickBrownDog, 50 | ExpectedHashOfQuickBrownFox, hash); 51 | } 52 | 53 | [TestMethod] 54 | public new void TestIncrementalHash() 55 | { 56 | TestHelper.TestIncrementalHash(TestConstants.QuickBrownDog, 57 | ExpectedHashOfQuickBrownFox, hash.Clone()); 58 | } 59 | 60 | [TestMethod] 61 | public void TestHMACCloneIsCorrect() 62 | { 63 | TestHelper.TestHMACCloneIsCorrect(hash); 64 | } 65 | } 66 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Crypto/GostTests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Crypto.Tests 31 | { 32 | [TestClass] 33 | public class GostTests : CryptoHashBaseTests 34 | { 35 | public GostTests() 36 | { 37 | hash = HashFactory.Crypto.CreateGost(); 38 | 39 | ExpectedHashOfEmptyData = "CE85B99CC46752FFFEE35CAB9A7B0278ABB4C2D2055CFF685AF4912C49490F8D"; 40 | ExpectedHashOfDefaultData = "21DCCFBF20D313170333BA15596338FB5964267328EB42CA10E269B7045FF856"; 41 | ExpectedHashOfOnetoNine = "264B4E433DEE474AEC465FA9C725FE963BC4B4ABC4FDAC63B7F73B671663AFC9"; 42 | ExpectedHashOfabcde = "B18CFD04F92DC1D83325036BC723D36DB25EDE41AE879D2545FC7F377B700899"; 43 | ExpectedHashOfDefaultDataWithHMACWithLongKey = "DE9D68F7793C829E7369AC09493A7749B2637A7B1D572A70549936E09F2D1D82"; 44 | ExpectedHashOfDefaultDataWithHMACWithShortKey = "6E4E2895E194BEB0A083B1DED6C4084F5E7F37BAAB988D288D9707235F2F8294"; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Crypto/Grindahl256Tests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Crypto.Tests 31 | { 32 | [TestClass] 33 | public class Grindahl256Tests : CryptoHashBaseTests 34 | { 35 | public Grindahl256Tests() 36 | { 37 | hash = HashFactory.Crypto.CreateGrindahl256(); 38 | 39 | ExpectedHashOfEmptyData = "45A7600159AF54AE110FCB6EA0F38AD57875EAC814F74D2CBC247D28C89923E6"; 40 | ExpectedHashOfDefaultData = "AC72E90B0F3F5864A0AF3C43E2A73E393DEBF22AB81B6786ADE22B4517DAAAB6"; 41 | ExpectedHashOfOnetoNine = "D2460846C5FE9E4750985CC9244D2458BEFD884435121FE56528022A3C7605B7"; 42 | ExpectedHashOfabcde = "5CDA73422F36E41087795BB6C21D577BAAF114E4A6CCF33D919E700EE2489FE2"; 43 | ExpectedHashOfDefaultDataWithHMACWithLongKey = "02D964EE346B0C333CEC0F5D7E68C5CFAAC1E3CB0C06FE36418E17AA3AFCA2BE"; 44 | ExpectedHashOfDefaultDataWithHMACWithShortKey = "65BA6F8EFA5B566D556EC8E3A2EC67DB7EE9BDEE663F17A8B8E7FAD067481023"; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Crypto/Grindahl512Tests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Crypto.Tests 31 | { 32 | [TestClass] 33 | public class Grindahl512Tests : CryptoHashBaseTests 34 | { 35 | public Grindahl512Tests() 36 | { 37 | hash = HashFactory.Crypto.CreateGrindahl512(); 38 | 39 | ExpectedHashOfEmptyData = "EE0BA85F90B6D232430BA43DD0EDD008462591816962A355602ED214FAAE54A9A4607D6F577CE950421FF58AEA53F51A7A9F5CCA894C3776104D43568FEA1207"; 40 | ExpectedHashOfDefaultData = "540F3C6A5070DA391BBA7121DB8F8745752D3515164498FC82CB5B4D837632CF3F256D85C4A0B7F34A86936FAB07BDA2DF2BFDD59AFDBD901E1347C2001DB1AD"; 41 | ExpectedHashOfOnetoNine = "6845F20B8A9DB083F307844506D342ED0FEE0D16BAF64B22E6C07552CB8C907E936FEDCD885B72C1B05813F722B5706C112AD59D3421CFD88CAA1CFB40EF1BEF"; 42 | ExpectedHashOfabcde = "F282C47F31831EAB58B8EE9D1EEE3B9B5A6A86354EEFE84CA3176BED5AB447E6D5AC82316F2D6FAAD350848E2D418336A57772D96311DA8BC51C93087204C6A5"; 43 | ExpectedHashOfDefaultDataWithHMACWithLongKey = "59A3F868AE1844BA9B683760D62C73E6E254BE6F46DF923F45118F32E9E1AB80A9056AA8A4792F0D6B8C709919C0ACC64EF64FC013C919758841AE6026F47E61"; 44 | ExpectedHashOfDefaultDataWithHMACWithShortKey = "7F067A454A4F6300982CAE37900171C627992A75A5567E0D3A51BC6672F79C5AC0CEF5978E933B713F38494DDF26114994C47689AC93EEC9B8EF7892C3B24087"; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Crypto/HAS160Tests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Crypto.Tests 31 | { 32 | [TestClass] 33 | public class HAS160Tests : CryptoHashBaseTests 34 | { 35 | public HAS160Tests() 36 | { 37 | hash = HashFactory.Crypto.CreateHAS160(); 38 | 39 | ExpectedHashOfEmptyData = "307964EF34151D37C8047ADEC7AB50F4FF89762D"; 40 | ExpectedHashOfDefaultData = "2773EDAC4501514254D7B1DF091D6B7652250A52"; 41 | ExpectedHashOfOnetoNine = "A0DA48CCD36C9D24AA630D4B3673525E9109A83C"; 42 | ExpectedHashOfabcde = "EEEA94C2F0450B639BC2ACCAF4AEB172A5885313"; 43 | ExpectedHashOfDefaultDataWithHMACWithLongKey = "7D2F0051F2BD817A4C27F126882353BCD300B7CA"; 44 | ExpectedHashOfDefaultDataWithHMACWithShortKey = "53970A7AC510A85D0E22FF506FED5B57188A8B3F"; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Crypto/Keccak_224Tests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Crypto.Tests 31 | { 32 | [TestClass] 33 | public class Keccak_224Tests : CryptoHashBaseTests 34 | { 35 | public Keccak_224Tests() 36 | { 37 | hash = HashFactory.Crypto.CreateKeccak_224(); 38 | 39 | ExpectedHashOfEmptyData = "F71837502BA8E10837BDD8D365ADB85591895602FC552B48B7390ABD"; 40 | ExpectedHashOfDefaultData = "1BA678212F840E95F076B4E3E75310D4DA4308E04396E07EF1683ACE"; 41 | ExpectedHashOfOnetoNine = "06471DE6C635A88E7470284B2C2EBF9BD7E5E888CBBD128C21CB8308"; 42 | ExpectedHashOfabcde = "16F91F7E036DF526340440C34C231862D8F6319772B670EEFD4703FF"; 43 | ExpectedHashOfDefaultDataWithHMACWithLongKey = "8C500F95CB013CBC16DEB6CB742D470E20404E0A1776647EAAB6E869"; 44 | ExpectedHashOfDefaultDataWithHMACWithShortKey = "D6CE783743A36717F893DFF82DE89633F21089AFBE4F26431E269650"; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Crypto/Keccak_256Tests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Crypto.Tests 31 | { 32 | [TestClass] 33 | public class Keccak_256Tests : CryptoHashBaseTests 34 | { 35 | public Keccak_256Tests() 36 | { 37 | hash = HashFactory.Crypto.CreateKeccak_256(); 38 | 39 | ExpectedHashOfEmptyData = "C5D2460186F7233C927E7DB2DCC703C0E500B653CA82273B7BFAD8045D85A470"; 40 | ExpectedHashOfDefaultData = "3FE42FE8CD6DAEF5ED7891846577F56AB35DC806424FC84A494C81E73BB06B5F"; 41 | ExpectedHashOfOnetoNine = "2A359FEEB8E488A1AF2C03B908B3ED7990400555DB73E1421181D97CAC004D48"; 42 | ExpectedHashOfabcde = "6377C7E66081CB65E473C1B95DB5195A27D04A7108B468890224BEDBE1A8A6EB"; 43 | ExpectedHashOfDefaultDataWithHMACWithLongKey = "925FE69CEF38AA0D2CCBF6741ADD808F204CAA64EFA7E301A0A3EC332E40075E"; 44 | ExpectedHashOfDefaultDataWithHMACWithShortKey = "1660234E7CCC29CFC8DEC8C6508AAF54EE48004EA9B56A15AC5742C89AAADA08"; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Crypto/Keccak_288Tests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Crypto.Tests 31 | { 32 | [TestClass] 33 | public class Keccak_288Tests : CryptoHashBaseTests 34 | { 35 | public Keccak_288Tests() 36 | { 37 | hash = HashFactory.Crypto.CreateKeccak_288(); 38 | 39 | ExpectedHashOfEmptyData = "6753E3380C09E385D0339EB6B050A68F66CFD60A73476E6FD6ADEB72F5EDD7C6F04A5D01"; 40 | ExpectedHashOfDefaultData = "A81F64CA8FAFFA1FC64A8E40E3F6A6FEA3303753B8F7F25E7E6EABA3D99A13F1EDF0F125"; 41 | ExpectedHashOfOnetoNine = "2B87D3D1907AA78236C7037752CA8C456611C24CE8FBAAAC961AABF3137B471C93A8F031"; 42 | ExpectedHashOfabcde = "F996518E4703A5D660B250D720A143B0A44C5DE31819A82FEF0F30158D18E74E6DF405F6"; 43 | ExpectedHashOfDefaultDataWithHMACWithLongKey = "EDC893C0E0E9E70F299098D5049D82EE6811582B93B5C38A5DC9FD14F984A352042365D0"; 44 | ExpectedHashOfDefaultDataWithHMACWithShortKey = "615143BAA85817D4F6F051E33801A900AEA480E716A01826E1392743A92B46EED587E9F7"; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Crypto/Keccak_384Tests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Crypto.Tests 31 | { 32 | [TestClass] 33 | public class Keccak_384Tests : CryptoHashBaseTests 34 | { 35 | public Keccak_384Tests() 36 | { 37 | hash = HashFactory.Crypto.CreateKeccak_384(); 38 | 39 | ExpectedHashOfEmptyData = "2C23146A63A29ACF99E73B88F8C24EAA7DC60AA771780CCC006AFBFA8FE2479B2DD2B21362337441AC12B515911957FF"; 40 | ExpectedHashOfDefaultData = "6A53977DFA0BCDCF069635CF541AB64C7E41923FCB3A5B049AB98878411D0E71DF95FCAB0072F1AE8B931BF4490B823E"; 41 | ExpectedHashOfOnetoNine = "EFCCAE72CE14656C434751CF737E70A57AB8DD2C76F5ABE01E52770AFFD77B66D2B80977724A00A6D971B702906F8032"; 42 | ExpectedHashOfabcde = "6E577A02A783232ACF34841399883F5F69D9AC78F48C7F4431CBC4F669C2A0F1CA3B1BECB7701B8315588D64D6C3746A"; 43 | ExpectedHashOfDefaultDataWithHMACWithLongKey = "A7740E29EEF80306DA09D7AF0868E925D6144996F99A01F973F03C4BD85D1EC20567936CA34A443B62A890AD8D263D2A"; 44 | ExpectedHashOfDefaultDataWithHMACWithShortKey = "044628643016E3EA30DE6CA3A8A1276F6BF1A5443CEF96BAA73199CF64FFC52D7F38254C671DB2933FFC8DD3E5B77223"; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Crypto/Keccak_512Tests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Crypto.Tests 31 | { 32 | [TestClass] 33 | public class Keccak_512Tests : CryptoHashBaseTests 34 | { 35 | public Keccak_512Tests() 36 | { 37 | hash = HashFactory.Crypto.CreateKeccak_512(); 38 | 39 | ExpectedHashOfEmptyData = "0EAB42DE4C3CEB9235FC91ACFFE746B29C29A8C366B7C60E4E67C466F36A4304C00FA9CAF9D87976BA469BCBE06713B435F091EF2769FB160CDAB33D3670680E"; 40 | ExpectedHashOfDefaultData = "27E67744299C2229F5008141E410B650BB7D70366B8A60BEAE52F8D6F4A8889D1BAEF53191FF53277FD6CFFE76937CDFAC40EB8EE6F32E3B146C05F961E970A8"; 41 | ExpectedHashOfOnetoNine = "40B787E94778266FB196A73B7A77EDF9DE2EF172451A2B87531324812250DF8F26FCC11E69B35AFDDBE639956C96153E71363F97010BC99405DD2D77B8C41986"; 42 | ExpectedHashOfabcde = "37491BD4BF2A4629D4E35602E09812FA94BFC63BAEE4487075E2B6D73F36D01A7392A1719EDBBB5D1D6FA3BA0D144F18229ABC13B7933A4736D6AAB4A3177F18"; 43 | ExpectedHashOfDefaultDataWithHMACWithLongKey = "53D5520C2E31F7EAAE1D95CF04663B18C2144AAF141F2630D6454162B3A890D75D59A9D99096411870FBF7A92A563AEA35AFED836DF652C6DF2AB4D373A754E3"; 44 | ExpectedHashOfDefaultDataWithHMACWithShortKey = "6FA826F0AFFE589DFD1665264F5516D076F9FEC585FD4227095B467A50E963D45C1730232549E8DDB590C1518BA310612839BBCCDF34F6A0AD6AC8B91D393BE6"; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Crypto/MD2Tests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Crypto.Tests 31 | { 32 | [TestClass] 33 | public class MD2Tests : CryptoHashBaseTests 34 | { 35 | public MD2Tests() 36 | { 37 | hash = HashFactory.Crypto.CreateMD2(); 38 | 39 | ExpectedHashOfEmptyData = "8350E5A3E24C153DF2275C9F80692773"; 40 | ExpectedHashOfDefaultData = "DFBE28FF5A3C23CAA85BE5848F16524E"; 41 | ExpectedHashOfOnetoNine = "12BD4EFDD922B5C8C7B773F26EF4E35F"; 42 | ExpectedHashOfabcde = "DFF9959487649F5C7AF5D0680A9A5D22"; 43 | ExpectedHashOfDefaultDataWithHMACWithLongKey = "03D7546FEADF29A91CEB40290A27E081"; 44 | ExpectedHashOfDefaultDataWithHMACWithShortKey = "C5F4625462CD5CF7723C19E8566F6790"; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Crypto/MD4Tests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Crypto.Tests 31 | { 32 | [TestClass] 33 | public class MD4Tests : CryptoHashBaseTests 34 | { 35 | public MD4Tests() 36 | { 37 | hash = HashFactory.Crypto.CreateMD4(); 38 | 39 | ExpectedHashOfEmptyData = "31D6CFE0D16AE931B73C59D7E0C089C0"; 40 | ExpectedHashOfDefaultData = "A77EAB8C3432FD9DD1B87C3C5C2E9C3C"; 41 | ExpectedHashOfOnetoNine = "2AE523785D0CAF4D2FB557C12016185C"; 42 | ExpectedHashOfabcde = "9803F4A34E8EB14F96ADBA49064A0C41"; 43 | ExpectedHashOfDefaultDataWithHMACWithLongKey = "7E30F4DA95992DBA450E345641DE5CEC"; 44 | ExpectedHashOfDefaultDataWithHMACWithShortKey = "BF21F9EC05E480EEDB12AF20181713E3"; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Crypto/MD5Tests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Crypto.Tests 31 | { 32 | [TestClass] 33 | public class MD5Tests : CryptoHashBaseTests 34 | { 35 | public MD5Tests() 36 | { 37 | hash = HashFactory.Crypto.CreateMD5(); 38 | 39 | ExpectedHashOfEmptyData = "D41D8CD98F00B204E9800998ECF8427E"; 40 | ExpectedHashOfDefaultData = "462EC1E50C8F2D5C387682E98F9BC842"; 41 | ExpectedHashOfOnetoNine = "25F9E794323B453885F5181F1B624D0B"; 42 | ExpectedHashOfabcde = "AB56B4D92B40713ACC5AF89985D4B786"; 43 | ExpectedHashOfDefaultDataWithHMACWithLongKey = "696D0706C43816B551D874B9B3E4B7E6"; 44 | ExpectedHashOfDefaultDataWithHMACWithShortKey = "09F705F43799213192622CCA6DF68941"; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Crypto/PanamaTests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Crypto.Tests 31 | { 32 | [TestClass] 33 | public class PanamaTests : CryptoHashBaseTests 34 | { 35 | public PanamaTests() 36 | { 37 | hash = HashFactory.Crypto.CreatePanama(); 38 | 39 | ExpectedHashOfEmptyData = "AA0CC954D757D7AC7779CA3342334CA471ABD47D5952AC91ED837ECD5B16922B"; 40 | ExpectedHashOfDefaultData = "69A05A5A5DDB32F5589257458BBDD059FB30C4486C052D81029DDB2864E90813"; 41 | ExpectedHashOfOnetoNine = "3C83D2C9109DE4D1FA64833683A7C280591A7CFD8516769EA879E56A4AD39B99"; 42 | ExpectedHashOfabcde = "B064E5476A3F511105B75305FC2EC31578A6B200FB5084CF937C179F1C52A891"; 43 | ExpectedHashOfDefaultDataWithHMACWithLongKey = "93226A060B4A82D1D9FBEE6B78424F8E3E871BE7DA77A9D17D5C78D5F415E631"; 44 | ExpectedHashOfDefaultDataWithHMACWithShortKey = "3C15C9B7CDC77470BC02CA96711B66FAA976AC2044F6F177ABCA93B1442EA376"; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Crypto/RIPEMD128Tests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Crypto.Tests 31 | { 32 | [TestClass] 33 | public class RIPEMD128Tests : CryptoHashBaseTests 34 | { 35 | public RIPEMD128Tests() 36 | { 37 | hash = HashFactory.Crypto.CreateRIPEMD128(); 38 | 39 | ExpectedHashOfEmptyData = "CDF26213A150DC3ECB610F18F6B38B46"; 40 | ExpectedHashOfDefaultData = "75891B00B2874EDCAF7002CA98264193"; 41 | ExpectedHashOfOnetoNine = "1886DB8ACDCBFEAB1E7EE3780400536F"; 42 | ExpectedHashOfabcde = "A0A954BE2A779BFB2129B72110C5782D"; 43 | ExpectedHashOfDefaultDataWithHMACWithLongKey = "E93930A64EF6807C4D80EF30DF86AFA7"; 44 | ExpectedHashOfDefaultDataWithHMACWithShortKey = "BA844D13A1215E20634A49D5599197EF"; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Crypto/RIPEMD160Tests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Crypto.Tests 31 | { 32 | [TestClass] 33 | public class RIPEMD160Tests : CryptoHashBaseTests 34 | { 35 | public RIPEMD160Tests() 36 | { 37 | hash = HashFactory.Crypto.CreateRIPEMD160(); 38 | 39 | ExpectedHashOfEmptyData = "9C1185A5C5E9FC54612808977EE8F548B2258D31"; 40 | ExpectedHashOfDefaultData = "0B8EAC9A2EA1E267750CE639D83A84B92631462B"; 41 | ExpectedHashOfOnetoNine = "D3D0379126C1E5E0BA70AD6E5E53FF6AEAB9F4FA"; 42 | ExpectedHashOfabcde = "973398B6E6C6CFA6B5E6A5173F195CE3274BF828"; 43 | ExpectedHashOfDefaultDataWithHMACWithLongKey = "4C373970BDB829BE3B6E0B2D9F510E9C35C9B583"; 44 | ExpectedHashOfDefaultDataWithHMACWithShortKey = "76D728D9BF39ED42E0C451A9526E3F0D929F067D"; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Crypto/RIPEMD256Tests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Crypto.Tests 31 | { 32 | [TestClass] 33 | public class RIPEMD256Tests : CryptoHashBaseTests 34 | { 35 | public RIPEMD256Tests() 36 | { 37 | hash = HashFactory.Crypto.CreateRIPEMD256(); 38 | 39 | ExpectedHashOfEmptyData = "02BA4C4E5F8ECD1877FC52D64D30E37A2D9774FB1E5D026380AE0168E3C5522D"; 40 | ExpectedHashOfDefaultData = "95EF1FFAB0EF6229F58CAE347426ADE3C412BCEB1057DAED0062BBDEE4BEACC6"; 41 | ExpectedHashOfOnetoNine = "6BE43FF65DD40EA4F2FF4AD58A7C1ACC7C8019137698945B16149EB95DF244B7"; 42 | ExpectedHashOfabcde = "81D8B58A3110A9139B4DDECCB031409E8AF023067CF4C6F0B701DAB9ECC0EB4E"; 43 | ExpectedHashOfDefaultDataWithHMACWithLongKey = "F1149704222B7ABA1F9C14B0E9A67909C53605E07614CF8C47CB357083EA3A6B"; 44 | ExpectedHashOfDefaultDataWithHMACWithShortKey = "D59B820A708FA31C39BD33BA88CB9A25516A3BA2BA99A74223FCE0EC0F9BFB1B"; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Crypto/RIPEMD320Tests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Crypto.Tests 31 | { 32 | [TestClass] 33 | public class RIPEMD320Tests : CryptoHashBaseTests 34 | { 35 | public RIPEMD320Tests() 36 | { 37 | hash = HashFactory.Crypto.CreateRIPEMD320(); 38 | 39 | ExpectedHashOfEmptyData = "22D65D5661536CDC75C1FDF5C6DE7B41B9F27325EBC61E8557177D705A0EC880151C3A32A00899B8"; 40 | ExpectedHashOfDefaultData = "004A1899CCA02BFD4055129304D55F364E35F033BB74B784AFC93F7268291D8AF84F2C64C5CCACD0"; 41 | ExpectedHashOfOnetoNine = "7E36771775A8D279475D4FD76B0C8E412B6AD085A0002475A148923CCFA5D71492E12FA88EEAF1A9"; 42 | ExpectedHashOfabcde = "A94DC1BC825DB64E97718305CE36BFEF32CC5410A630999678BCD89CC38C424269012EC8C5A95830"; 43 | ExpectedHashOfDefaultDataWithHMACWithLongKey = "248D14ED08F0F49D175F4DC487A64B81F06D78077D1CF975BBE5D47627995990EBE45E6B7EDF9362"; 44 | ExpectedHashOfDefaultDataWithHMACWithShortKey = "4D3DFCCB43E5A60611A850C2141086CB16752505BA12E1B7953EA8859CB1E1DF3A698562A46DB41C"; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Crypto/RIPEMDTests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Crypto.Tests 31 | { 32 | [TestClass] 33 | public class RIPEMDTests : CryptoHashBaseTests 34 | { 35 | public RIPEMDTests() 36 | { 37 | hash = HashFactory.Crypto.CreateRIPEMD(); 38 | 39 | ExpectedHashOfEmptyData = "9F73AA9B372A9DACFB86A6108852E2D9"; 40 | ExpectedHashOfDefaultData = "B3F629A9786744AA105A2C150869C236"; 41 | ExpectedHashOfOnetoNine = "C905B44C6429AD0A1934550037D4816F"; 42 | ExpectedHashOfabcde = "68D2362617E85CF1BF7381DF14045DBB"; 43 | ExpectedHashOfDefaultDataWithHMACWithLongKey = "B06D09CE5452ADEEADF468E00DAC5C8B"; 44 | ExpectedHashOfDefaultDataWithHMACWithShortKey = "219ACFCF07BDB775FBA73DACE1E97E08"; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Crypto/RadioGatun32Tests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Crypto.Tests 31 | { 32 | [TestClass] 33 | public class RadioGatun32Tests : CryptoHashBaseTests 34 | { 35 | public RadioGatun32Tests() 36 | { 37 | hash = HashFactory.Crypto.CreateRadioGatun32(); 38 | 39 | ExpectedHashOfEmptyData = "F30028B54AFAB6B3E55355D277711109A19BEDA7091067E9A492FB5ED9F20117"; 40 | ExpectedHashOfDefaultData = "17B20CF19B3FC84FD2FFE084F07D4CD4DBBC50E41048D8259EB963B0A7B9C784"; 41 | ExpectedHashOfOnetoNine = "D77629174F56D8451F73CBE80EC7A20EF2DD65C46A1480CD004CBAA96F3FA1FD"; 42 | ExpectedHashOfabcde = "A593059B12513A1BD88A2D433F07B239BC14743AF0FF7294837B5DF756BF9C7A"; 43 | ExpectedHashOfDefaultDataWithHMACWithLongKey = "CD48D590665EA2C066A0C26E2620D567C75090DE38045B88C53BFAE685D67886"; 44 | ExpectedHashOfDefaultDataWithHMACWithShortKey = "72EB7D36180C1B1BBF88E062FEC7419DBB4849892623D332821C1B0D71D6D513"; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Crypto/RadioGatun64Tests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Crypto.Tests 31 | { 32 | [TestClass] 33 | public class RadioGatun64Tests : CryptoHashBaseTests 34 | { 35 | public RadioGatun64Tests() 36 | { 37 | hash = HashFactory.Crypto.CreateRadioGatun64(); 38 | 39 | ExpectedHashOfEmptyData = "64A9A7FA139905B57BDAB35D33AA216370D5EAE13E77BFCDD85513408311A584"; 40 | ExpectedHashOfDefaultData = "43B3208CE2E6B23D985087A84BD583F713A9002280BF2785B1EE569B12C15054"; 41 | ExpectedHashOfOnetoNine = "76A565017A42B258F5C8C9D2D9FD4C7347947A659ED142FF61C1BEA592F103C5"; 42 | ExpectedHashOfabcde = "36B4DD23A97424844662E882AD1DA1DBAD8CB435A57F380455393C9FF9DE9D37"; 43 | ExpectedHashOfDefaultDataWithHMACWithLongKey = "B9CBBB9FE06144CF5E369BDBBCB2C76EBBE8904061C356BA9A06FE2D96E4037F"; 44 | ExpectedHashOfDefaultDataWithHMACWithShortKey = "FA280F80C1323C32AACC7F1CAB3808FE2BB8880F901AE6F03BD14D6D1884B267"; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Crypto/SHA0Tests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Crypto.Tests 31 | { 32 | [TestClass] 33 | public class SHA0Tests : CryptoHashBaseTests 34 | { 35 | public SHA0Tests() 36 | { 37 | hash = HashFactory.Crypto.CreateSHA0(); 38 | 39 | ExpectedHashOfEmptyData = "F96CEA198AD1DD5617AC084A3D92C6107708C0EF"; 40 | ExpectedHashOfDefaultData = "C9CBBE593DE122CA36B13CC37FE2CA8D5606FEED"; 41 | ExpectedHashOfOnetoNine = "F0360779D2AF6615F306BB534223CF762A92E988"; 42 | ExpectedHashOfabcde = "D624E34951BB800F0ACAE773001DF8CFFE781BA8"; 43 | ExpectedHashOfDefaultDataWithHMACWithLongKey = "CDA87167A558311B9154F372F21A453030BBE16A"; 44 | ExpectedHashOfDefaultDataWithHMACWithShortKey = "EAA73E85DCAC5BAD0A0E71C0695F901FC32DB38A"; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Crypto/SHA1Tests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Crypto.Tests 31 | { 32 | [TestClass] 33 | public class SHA1Tests : CryptoHashBaseTests 34 | { 35 | public SHA1Tests() 36 | { 37 | hash = HashFactory.Crypto.CreateSHA1(); 38 | 39 | ExpectedHashOfEmptyData = "DA39A3EE5E6B4B0D3255BFEF95601890AFD80709"; 40 | ExpectedHashOfDefaultData = "C8389876E94C043C47BA4BFF3D359884071DC310"; 41 | ExpectedHashOfOnetoNine = "F7C3BC1D808E04732ADF679965CCC34CA7AE3441"; 42 | ExpectedHashOfabcde = "03DE6C570BFE24BFC328CCD7CA46B76EADAF4334"; 43 | ExpectedHashOfDefaultDataWithHMACWithLongKey = "E70699720F4222E3A4A4474F14F13CBC3316D9B2"; 44 | ExpectedHashOfDefaultDataWithHMACWithShortKey = "CD409025AA5F34ABDC660856463155B23C89B16A"; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Crypto/SHA2_224Tests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Crypto.Tests 31 | { 32 | [TestClass] 33 | public class SHA2_224Tests : CryptoHashBaseTests 34 | { 35 | public SHA2_224Tests() 36 | { 37 | hash = HashFactory.Crypto.CreateSHA2_224(); 38 | 39 | ExpectedHashOfEmptyData = "D14A028C2A3A2BC9476102BB288234C415A2B01F828EA62AC5B3E42F"; 40 | ExpectedHashOfDefaultData = "DF2B86ED008508F542443C4B1810AA5A0F5658692B808EEB1D0A2F7E"; 41 | ExpectedHashOfOnetoNine = "9B3E61BF29F17C75572FAE2E86E17809A4513D07C8A18152ACF34521"; 42 | ExpectedHashOfabcde = "BDD03D560993E675516BA5A50638B6531AC2AC3D5847C61916CFCED6"; 43 | ExpectedHashOfDefaultDataWithHMACWithLongKey = "86855E59D8B09A3C7632D4E176C4B65C549255F417FEF9EEF2D4167D"; 44 | ExpectedHashOfDefaultDataWithHMACWithShortKey = "EC47E83DB5DD735EBB7AA4A898460950B16A3A0FA48E4BB9184EA3D1"; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Crypto/SHA2_256Tests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Crypto.Tests 31 | { 32 | [TestClass] 33 | public class SHA2_256Tests : CryptoHashBaseTests 34 | { 35 | public SHA2_256Tests() 36 | { 37 | hash = HashFactory.Crypto.CreateSHA2_256(); 38 | 39 | ExpectedHashOfEmptyData = "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855"; 40 | ExpectedHashOfDefaultData = "BCF45544CB98DDAB731927F8760F81821489ED04C0792A4D254134887BEA9E38"; 41 | ExpectedHashOfOnetoNine = "15E2B0D3C33891EBB0F1EF609EC419420C20E320CE94C65FBC8C3312448EB225"; 42 | ExpectedHashOfabcde = "36BBE50ED96841D10443BCB670D6554F0A34B761BE67EC9C4A8AD2C0C44CA42C"; 43 | ExpectedHashOfDefaultDataWithHMACWithLongKey = "BC05A7D3B13A4A67445C62389564D35B18F33A0C6408EC8DA0CB2506AE6E2D14"; 44 | ExpectedHashOfDefaultDataWithHMACWithShortKey = "92678A1C746AAEAA1D3F0C9DAC4BCA73801D278B51C1F6861D49C9A2C1175687"; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Crypto/SHA2_384Tests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Crypto.Tests 31 | { 32 | [TestClass] 33 | public class SHA2_384Tests : CryptoHashBaseTests 34 | { 35 | public SHA2_384Tests() 36 | { 37 | hash = HashFactory.Crypto.CreateSHA2_384(); 38 | 39 | ExpectedHashOfEmptyData = "38B060A751AC96384CD9327EB1B1E36A21FDB71114BE07434C0CC7BF63F6E1DA274EDEBFE76F65FBD51AD2F14898B95B"; 40 | ExpectedHashOfDefaultData = "05D165ADA4A6F9F550CB6F9A0E00401E628B302FA5D7F3824361768758421F83102AC611B2710F5168579CFB11942869"; 41 | ExpectedHashOfOnetoNine = "EB455D56D2C1A69DE64E832011F3393D45F3FA31D6842F21AF92D2FE469C499DA5E3179847334A18479C8D1DEDEA1BE3"; 42 | ExpectedHashOfabcde = "4C525CBEAC729EAF4B4665815BC5DB0C84FE6300068A727CF74E2813521565ABC0EC57A37EE4D8BE89D097C0D2AD52F0"; 43 | ExpectedHashOfDefaultDataWithHMACWithLongKey = "162295D136DB47205EDF45BF8687E5599DFA80C6AE79D83C03E729C48D373E19638ADD5B5D603558234DF755404CCF9E"; 44 | ExpectedHashOfDefaultDataWithHMACWithShortKey = "3D6DCED731DAF3599CC0971646C1A8B8CCC61650722F111A9EB26CE7B65189EB220EACB09152D9A09065099FE6C1FDC9"; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Crypto/SHA2_512Tests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Crypto.Tests 31 | { 32 | [TestClass] 33 | public class SHA2_512Tests : CryptoHashBaseTests 34 | { 35 | public SHA2_512Tests() 36 | { 37 | hash = HashFactory.Crypto.CreateSHA2_512(); 38 | 39 | ExpectedHashOfEmptyData = "CF83E1357EEFB8BDF1542850D66D8007D620E4050B5715DC83F4A921D36CE9CE47D0D13C5D85F2B0FF8318D2877EEC2F63B931BD47417A81A538327AF927DA3E"; 40 | ExpectedHashOfDefaultData = "0A5DA12B113EBD3DEA4C51FD10AFECF1E2A8EE6C3848A0DD4407141ADDA04375068D85A1EEF980FAFF68DC3BF5B1B3FBA31344178042197B5180BD95530D61AC"; 41 | ExpectedHashOfOnetoNine = "D9E6762DD1C8EAF6D61B3C6192FC408D4D6D5F1176D0C29169BC24E71C3F274AD27FCD5811B313D681F7E55EC02D73D499C95455B6B5BB503ACF574FBA8FFE85"; 42 | ExpectedHashOfabcde = "878AE65A92E86CAC011A570D4C30A7EAEC442B85CE8ECA0C2952B5E3CC0628C2E79D889AD4D5C7C626986D452DD86374B6FFAA7CD8B67665BEF2289A5C70B0A1"; 43 | ExpectedHashOfDefaultDataWithHMACWithLongKey = "FB795F2A85271149E6A6E2668AAF54DB5946DC669C1C8432BED856AEC9A1A461B5FC13FE8AE0861E6A8F53D711FDDF76AC60A5CCC8BA334325FDB9472A7A71F4"; 44 | ExpectedHashOfDefaultDataWithHMACWithShortKey = "DEDFCEAD40225068527D0E53B7C892226E188891D939E21A0777A40EA2E29D7233638C178C879F26088A502A887674C01DF61EAF1635D707D114097ED1D0D762"; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Crypto/SHA2_512_224Tests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Crypto.Tests 31 | { 32 | [TestClass] 33 | public class SHA2_512_224Tests : CryptoHashBaseTests 34 | { 35 | public SHA2_512_224Tests() 36 | { 37 | hash = HashFactory.Crypto.CreateSHA2_512_224(); 38 | 39 | ExpectedHashOfEmptyData = "6ED0DD02806FA89E25DE060C19D3AC86CABB87D6A0DDD05C333B84F4"; 40 | ExpectedHashOfDefaultData = "7A95749FB7F4489A45275556F5D905D28E1B637DCDD6537336AB6234"; 41 | ExpectedHashOfOnetoNine = "F2A68A474BCBEA375E9FC62EAAB7B81FEFBDA64BB1C72D72E7C27314"; 42 | ExpectedHashOfabcde = "880E79BB0A1D2C9B7528D851EDB6B8342C58C831DE98123B432A4515"; 43 | ExpectedHashOfDefaultDataWithHMACWithLongKey = "B932866547894977F6E4C61D137FFC2508C639BA6786F45AC64731C8"; 44 | ExpectedHashOfDefaultDataWithHMACWithShortKey = "9BC318A84B90F7FF55C53E3F4B602EAD13BB579EB1794455B29562B4"; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Crypto/SHA2_512_256Tests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Crypto.Tests 31 | { 32 | [TestClass] 33 | public class SHA2_512_256Tests : CryptoHashBaseTests 34 | { 35 | public SHA2_512_256Tests() 36 | { 37 | hash = HashFactory.Crypto.CreateSHA2_512_256(); 38 | 39 | ExpectedHashOfEmptyData = "C672B8D1EF56ED28AB87C3622C5114069BDD3AD7B8F9737498D0C01ECEF0967A"; 40 | ExpectedHashOfDefaultData = "E1792BAAAEBFC58E213D0BA628BF2FF22CBA10526075702F7C1727B76BEB107B"; 41 | ExpectedHashOfOnetoNine = "1877345237853A31AD79E14C1FCB0DDCD3DF9973B61AF7F906E4B4D052CC9416"; 42 | ExpectedHashOfabcde = "DE8322B46E78B67D4431997070703E9764E03A1237B896FD8B379ED4576E8363"; 43 | ExpectedHashOfDefaultDataWithHMACWithLongKey = "5EF407B913662BE3D98F5DA20D55C2A45D3F3E4FF771B2C2A482E35F6A757E71"; 44 | ExpectedHashOfDefaultDataWithHMACWithShortKey = "1467239C9D47E1962905D03D7006170A04D05E4508BB47E30AD9481FBDA975FF"; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Crypto/SHA3_224Tests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Crypto.Tests 31 | { 32 | [TestClass] 33 | public class SHA3_224Tests : CryptoHashBaseTests 34 | { 35 | public SHA3_224Tests() 36 | { 37 | hash = HashFactory.Crypto.CreateSHA3_224(); 38 | 39 | ExpectedHashOfEmptyData = "6B4E03423667DBB73B6E15454F0EB1ABD4597F9A1B078E3F5B5A6BC7"; 40 | ExpectedHashOfDefaultData = "1D2BDFB95B0203C2BB7C739D813D69521EC7A3047E3FCA15CD305C95"; 41 | ExpectedHashOfOnetoNine = "5795C3D628FD638C9835A4C79A55809F265068C88729A1A3FCDF8522"; 42 | ExpectedHashOfabcde = "6ACFAAB70AFD8439CEA3616B41088BD81C939B272548F6409CF30E57"; 43 | ExpectedHashOfDefaultDataWithHMACWithLongKey = "38FABCD5E29DE7AD7429BD9124F804FFD340D7B9F77A83DC25EC53B8"; 44 | ExpectedHashOfDefaultDataWithHMACWithShortKey = "DA17722BA1E4BD728A83015A83430A67577F283A0EFCB457C327A980"; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Crypto/SHA3_256Tests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Crypto.Tests 31 | { 32 | [TestClass] 33 | public class SHA3_256Tests : CryptoHashBaseTests 34 | { 35 | public SHA3_256Tests() 36 | { 37 | hash = HashFactory.Crypto.CreateSHA3_256(); 38 | 39 | ExpectedHashOfEmptyData = "A7FFC6F8BF1ED76651C14756A061D662F580FF4DE43B49FA82D80A4B80F8434A"; 40 | ExpectedHashOfDefaultData = "C334674D808EBB8B7C2926F043D1CAE78D168A05B70B9210C9167EA6DC300CE2"; 41 | ExpectedHashOfOnetoNine = "87CD084D190E436F147322B90E7384F6A8E0676C99D21EF519EA718E51D45F9C"; 42 | ExpectedHashOfabcde = "D716EC61E18904A8F58679B71CB065D4D5DB72E0E0C3F155A4FEFF7ADD0E58EB"; 43 | ExpectedHashOfDefaultDataWithHMACWithLongKey = "B8EC49AF4DE71CB0561A9F0DF7B156CC7784AC044F12B65048CE6DBB27A57E66"; 44 | ExpectedHashOfDefaultDataWithHMACWithShortKey = "1019B70021A038345192F00D02E33FA4AF8949E80AD592C4671A438DCCBCFBDF"; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Crypto/SHA3_384Tests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Crypto.Tests 31 | { 32 | [TestClass] 33 | public class SHA3_384Tests : CryptoHashBaseTests 34 | { 35 | public SHA3_384Tests() 36 | { 37 | hash = HashFactory.Crypto.CreateSHA3_384(); 38 | 39 | ExpectedHashOfEmptyData = "0C63A75B845E4F7D01107D852E4C2485C51A50AAAA94FC61995E71BBEE983A2AC3713831264ADB47FB6BD1E058D5F004"; 40 | ExpectedHashOfDefaultData = "87DD2935CD0DDEFFB8694E70ED1D33EABCEA848BD93A7A7B7227603B7C080A70BCF29FCEED66F456A7FB593EB23F950C"; 41 | ExpectedHashOfOnetoNine = "8B90EDE4D095409F1A12492C2520599683A9478DC70B7566D23B3E41ECE8538C6CDE92382A5E38786490375C54672ABF"; 42 | ExpectedHashOfabcde = "348494236B82EDDA7602C78BA67FC3838E427C63C23E2C9D9AA5EA6354218A3C2CA564679ACABF3AC6BF5378047691C4"; 43 | ExpectedHashOfDefaultDataWithHMACWithLongKey = "802D520828C580A61EE4BFA138BE23708C22DB97F94913AF5897E3C9C12BA6C4EC33BFEB79691D2F302315B27674EA40"; 44 | ExpectedHashOfDefaultDataWithHMACWithShortKey = "52A4A926B60AA9F6B7DB1C8F5344A097540A8E2115164BF75734907E88C2BC1F7DD84D0EE8569B9857590A39EB5FF499"; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Crypto/SHA3_512Tests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Crypto.Tests 31 | { 32 | [TestClass] 33 | public class SHA3_512Tests : CryptoHashBaseTests 34 | { 35 | public SHA3_512Tests() 36 | { 37 | hash = HashFactory.Crypto.CreateSHA3_512(); 38 | 39 | ExpectedHashOfEmptyData = "A69F73CCA23A9AC5C8B567DC185A756E97C982164FE25859E0D1DCC1475C80A615B2123AF1F5F94C11E3E9402C3AC558F500199D95B6D3E301758586281DCD26"; 40 | ExpectedHashOfDefaultData = "FAA213B928B942C521FD2A4B5F918C9AB6479A1DD122B9485440E56E729976D57C5E7C62F65D8453DCAAADA6B79743DB939F22773FD44C9ECD54B4B7FAFDAE33"; 41 | ExpectedHashOfOnetoNine = "E1E44D20556E97A180B6DD3ED7AE5C465CAFD553FA8747DCA038FB95635B77A37318F7DDF7AEC1F6C3C14BB160BA2497007DECF38DD361CAB199E3B8C8FE1F5C"; 42 | ExpectedHashOfabcde = "1D7C3AA6EE17DA5F4AEB78BE968AA38476DBEE54842E1AE2856F4C9A5CD04D45DC75C2902182B07C130ED582D476995B502B8777CCF69F60574471600386639B"; 43 | ExpectedHashOfDefaultDataWithHMACWithLongKey = "ADD449377F25EC360F87B04AE6334D5D7CA90EAF3568D4EBDA3A977B820271952D7D93A7804E29B9791DC19FF7B523E6CCABED180B0B035CCDDA38A7E92DC7E0"; 44 | ExpectedHashOfDefaultDataWithHMACWithShortKey = "439C673B33F0F6D9273124782611EA96F1BB62F90672551310C1230ADAAD0D40F63C6D2B17DAFECEFD9CE8848576001D9D68FAD1B9E7DDC146F00CEBE5AFED27"; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Crypto/Snefru_8_128Tests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Crypto.Tests 31 | { 32 | [TestClass] 33 | public class Snefru_8_128Tests : CryptoHashBaseTests 34 | { 35 | public Snefru_8_128Tests() 36 | { 37 | hash = HashFactory.Crypto.CreateSnefru_8_128(); 38 | 39 | ExpectedHashOfEmptyData = "8617F366566A011837F4FB4BA5BEDEA2"; 40 | ExpectedHashOfDefaultData = "1EA32485C121D07D1BD22FC4EDCF554F"; 41 | ExpectedHashOfOnetoNine = "486D27B1F5F4A20DEE14CC466EDA9069"; 42 | ExpectedHashOfabcde = "ADD78FA0BEA8F6283FE5D011BE6BCA3B"; 43 | ExpectedHashOfDefaultDataWithHMACWithLongKey = "296DEC851C9F6A6C9E1FD42679CE3FD2"; 44 | ExpectedHashOfDefaultDataWithHMACWithShortKey = "B7D06604FCA943939525BA82BA69706E"; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Crypto/Snefru_8_256Tests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Crypto.Tests 31 | { 32 | [TestClass] 33 | public class Snefru_8_256Tests : CryptoHashBaseTests 34 | { 35 | public Snefru_8_256Tests() 36 | { 37 | hash = HashFactory.Crypto.CreateSnefru_8_256(); 38 | 39 | ExpectedHashOfEmptyData = "8617F366566A011837F4FB4BA5BEDEA2B892F3ED8B894023D16AE344B2BE5881"; 40 | ExpectedHashOfDefaultData = "230826DA59215F22AF36663491AECC4872F663722A5A7932428CB8196F7AF78D"; 41 | ExpectedHashOfOnetoNine = "1C7DEDC33125AF7517970B97B635777FFBA8905D7A0B359776E3E683B115F992"; 42 | ExpectedHashOfabcde = "8D2891FC6020D7DC93F7561C0CFDDE26426192B3E364A1F52B634482009DC8C8"; 43 | ExpectedHashOfDefaultDataWithHMACWithLongKey = "EEE63DC493FCDAA2F826FFF81DB4BAC53CBBFD933BEA3B65C8BEBB576D921623"; 44 | ExpectedHashOfDefaultDataWithHMACWithShortKey = "7E33D94C5A09B2E5F800417128BCF3EF2EDCB971884789A35AE4AA7F13A18147"; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Crypto/WhirlPoolTests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Crypto.Tests 31 | { 32 | [TestClass] 33 | public class WhirlPoolTests : CryptoHashBaseTests 34 | { 35 | public WhirlPoolTests() 36 | { 37 | hash = HashFactory.Crypto.CreateWhirlPool(); 38 | 39 | ExpectedHashOfEmptyData = "19FA61D75522A4669B44E39C1D2E1726C530232130D407F89AFEE0964997F7A73E83BE698B288FEBCF88E3E03C4F0757EA8964E59B63D93708B138CC42A66EB3"; 40 | ExpectedHashOfDefaultData = "9D2BB47D6F6D9F0DBAF08BEF416DE06C98CDF293F3D1AD2422A63A9ADFBD9AA33F888A1C6FE7C16DF33B2BD9FFD8EF160BCF6AB4F21B682DC238A3BE03AB0F12"; 41 | ExpectedHashOfOnetoNine = "21D5CB651222C347EA1284C0ACF162000B4D3E34766F0D00312E3480F633088822809B6A54BA7EDFA17E8FCB5713F8912EE3A218DD98D88C38BBF611B1B1ED2B"; 42 | ExpectedHashOfabcde = "5D745E26CCB20FE655D39C9E7F69455758FBAE541CB892B3581E4869244AB35B4FD6078F5D28B1F1A217452A67D9801033D92724A221255A5E377FE9E9E5F0B2"; 43 | ExpectedHashOfDefaultDataWithHMACWithLongKey = "A2CF231E2E01B310A91A7BF92435AE0258997AB969D0B2E09378C0F30C73E4434894A836B3F580683F58FC56DA87C685927AE0FC80D2548A35CD3C7528A83AC1"; 44 | ExpectedHashOfDefaultDataWithHMACWithShortKey = "72B3CFC10CC32F9203670984407594B9F2A6C9F1A46C3FF7DF76AD07207758F96CF46C448A7687EBBA5EBC046984B4837320306EB27978A58B8CF447978CADEA"; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Hash128/MurmurHash3_x64_128Tests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Hash128.Tests 31 | { 32 | [TestClass] 33 | public class MurmurHash3_x64_128Tests : HashWithUInt32AsKeyBaseTests 34 | { 35 | public MurmurHash3_x64_128Tests() 36 | { 37 | hash = HashFactory.Hash128.CreateMurmurHash3_x64_128(); 38 | 39 | ExpectedHashOfEmptyData = "00000000000000000000000000000000"; 40 | ExpectedHashOfDefaultData = "705BD3C954B94BE056F06B68662E6364"; 41 | ExpectedHashOfRandomString = "D30654ABBD8227E367D73523F0079673"; 42 | ExpectedHashOfZerotoFour = "0F04E459497F3FC1ECCC6223A28DD613"; 43 | ExpectedHashOfEmptyDataWithOneAsKey = "4610ABE56EFF5CB551622DAA78F83583"; 44 | ExpectedHashOfDefaultDataWithMaxUInt32AsKey = "ADFD14988FB1F8582A1B67C1BBACC218"; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Hash128/MurmurHash3_x86_128Tests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Hash128.Tests 31 | { 32 | [TestClass] 33 | public class MurmurHash3_x86_128Tests : HashWithUInt32AsKeyBaseTests 34 | { 35 | public MurmurHash3_x86_128Tests() 36 | { 37 | hash = HashFactory.Hash128.CreateMurmurHash3_x86_128(); 38 | 39 | ExpectedHashOfEmptyData = "00000000000000000000000000000000"; 40 | ExpectedHashOfDefaultData = "B35E1058738E067BF637B17075F14B8B"; 41 | ExpectedHashOfRandomString = "9B5B7BA2EF3F7866889ADEAF00F3F98E"; 42 | ExpectedHashOfZerotoFour = "35C5B3EE7B3B211600AE108800AE1088"; 43 | ExpectedHashOfEmptyDataWithOneAsKey = "88C4ADEC54D201B954D201B954D201B9"; 44 | ExpectedHashOfDefaultDataWithMaxUInt32AsKey = "55315FA9E8129C7390C080B8FDB1C972"; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Hash32/APTests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Hash32.Tests 31 | { 32 | [TestClass] 33 | public class APTests : HashAdapter1BaseTests 34 | { 35 | public APTests() 36 | { 37 | hash = HashFactory.Hash32.CreateAP(); 38 | 39 | ExpectedHashOfEmptyData = "AAAAAAAA"; 40 | ExpectedHashOfDefaultData = "7F14EFED"; 41 | ExpectedHashOfOnetoNine = "C0E86BE5"; 42 | ExpectedHashOfabcde = "7F6A697A"; 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Hash32/BKDRTests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Hash32.Tests 31 | { 32 | [TestClass] 33 | public class BKDRTests : HashAdapter1BaseTests 34 | { 35 | public BKDRTests() 36 | { 37 | hash = HashFactory.Hash32.CreateBKDR(); 38 | 39 | ExpectedHashOfEmptyData = "00000000"; 40 | ExpectedHashOfDefaultData = "29E11B15"; 41 | ExpectedHashOfOnetoNine = "DE43D6D5"; 42 | ExpectedHashOfabcde = "B3EDEA13"; 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Hash32/Bernstein1Tests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Hash32.Tests 31 | { 32 | [TestClass] 33 | public class Bernstein1Tests : HashAdapter1BaseTests 34 | { 35 | public Bernstein1Tests() 36 | { 37 | hash = HashFactory.Hash32.CreateBernstein1(); 38 | 39 | ExpectedHashOfEmptyData = "00001505"; 40 | ExpectedHashOfDefaultData = "2D122E48"; 41 | ExpectedHashOfOnetoNine = "3BABEA14"; 42 | ExpectedHashOfabcde = "0A1DEB04"; 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Hash32/BernsteinTests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Hash32.Tests 31 | { 32 | [TestClass] 33 | public class BernsteinTests : HashAdapter1BaseTests 34 | { 35 | public BernsteinTests() 36 | { 37 | hash = HashFactory.Hash32.CreateBernstein(); 38 | 39 | ExpectedHashOfEmptyData = "00001505"; 40 | ExpectedHashOfDefaultData = "C4635F48"; 41 | ExpectedHashOfOnetoNine = "35CDBB82"; 42 | ExpectedHashOfabcde = "0F11B894"; 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Hash32/DEKTests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Hash32.Tests 31 | { 32 | [TestClass] 33 | public class DEKTests : HashAdapter1BaseTests 34 | { 35 | public DEKTests() 36 | { 37 | hash = HashFactory.Hash32.CreateDEK(); 38 | 39 | ExpectedHashOfEmptyData = "00000000"; 40 | ExpectedHashOfDefaultData = "8E01E947"; 41 | ExpectedHashOfOnetoNine = "AB4ACBA5"; 42 | ExpectedHashOfabcde = "0C2080E5"; 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Hash32/DJBTests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Hash32.Tests 31 | { 32 | [TestClass] 33 | public class DJBTests : HashAdapter1BaseTests 34 | { 35 | public DJBTests() 36 | { 37 | hash = HashFactory.Hash32.CreateDJB(); 38 | 39 | ExpectedHashOfEmptyData = "00001505"; 40 | ExpectedHashOfDefaultData = "C4635F48"; 41 | ExpectedHashOfOnetoNine = "35CDBB82"; 42 | ExpectedHashOfabcde = "0F11B894"; 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Hash32/ELFTests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Hash32.Tests 31 | { 32 | [TestClass] 33 | public class ELFTests : HashAdapter1BaseTests 34 | { 35 | public ELFTests() 36 | { 37 | hash = HashFactory.Hash32.CreateELF(); 38 | 39 | ExpectedHashOfEmptyData = "00000000"; 40 | ExpectedHashOfDefaultData = "01F5B2CC"; 41 | ExpectedHashOfOnetoNine = "0678AEE9"; 42 | ExpectedHashOfabcde = "006789A5"; 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Hash32/FNV1aTests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Hash32.Tests 31 | { 32 | [TestClass] 33 | public class FNV1aTests : HashAdapter1BaseTests 34 | { 35 | public FNV1aTests() 36 | { 37 | hash = HashFactory.Hash32.CreateFNV1a(); 38 | 39 | ExpectedHashOfEmptyData = "811C9DC5"; 40 | ExpectedHashOfDefaultData = "1892F1F8"; 41 | ExpectedHashOfOnetoNine = "BB86B11C"; 42 | ExpectedHashOfabcde = "749BCF08"; 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Hash32/FNVTests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Hash32.Tests 31 | { 32 | [TestClass] 33 | public class FNVTests : HashAdapter1BaseTests 34 | { 35 | public FNVTests() 36 | { 37 | hash = HashFactory.Hash32.CreateFNV(); 38 | 39 | ExpectedHashOfEmptyData = "00000000"; 40 | ExpectedHashOfDefaultData = "BE611EA3"; 41 | ExpectedHashOfOnetoNine = "D8D70BF1"; 42 | ExpectedHashOfabcde = "B2B39969"; 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Hash32/JSTests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Hash32.Tests 31 | { 32 | [TestClass] 33 | public class JSTests : HashAdapter1BaseTests 34 | { 35 | public JSTests() 36 | { 37 | hash = HashFactory.Hash32.CreateJS(); 38 | 39 | ExpectedHashOfEmptyData = "4E67C6A7"; 40 | ExpectedHashOfDefaultData = "683AFCFE"; 41 | ExpectedHashOfOnetoNine = "90A4224B"; 42 | ExpectedHashOfabcde = "62E8C8B5"; 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Hash32/Jenkins3Tests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Hash32.Tests 31 | { 32 | [TestClass] 33 | public class Jenkins3Tests : HashAdapter1BaseTests 34 | { 35 | public Jenkins3Tests() 36 | { 37 | hash = HashFactory.Hash32.CreateJenkins3(); 38 | 39 | ExpectedHashOfEmptyData = "00000000"; 40 | ExpectedHashOfDefaultData = "F0F69CEF"; 41 | ExpectedHashOfOnetoNine = "845D9A96"; 42 | ExpectedHashOfabcde = "026D72DE"; 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Hash32/Murmur2Tests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | using SharpHash.Interfaces; 30 | using SharpHash.Tests; 31 | using SharpHash.Utils; 32 | using System; 33 | using System.Text; 34 | 35 | namespace SharpHash.Hash32.Tests 36 | { 37 | [TestClass] 38 | public class Murmur2Tests : HashAdapter1BaseTests 39 | { 40 | private string ExpectedHashOfDefaultDataWithMaxUInt32AsKey { get; set; } 41 | 42 | public Murmur2Tests() 43 | { 44 | hash = HashFactory.Hash32.CreateMurmur2(); 45 | 46 | ExpectedHashOfEmptyData = "00000000"; 47 | ExpectedHashOfDefaultData = "30512DE6"; 48 | ExpectedHashOfOnetoNine = "DCCB0167"; 49 | ExpectedHashOfabcde = "5F09A8DE"; 50 | ExpectedHashOfDefaultDataWithMaxUInt32AsKey = "B15D52F0"; 51 | } 52 | 53 | [TestMethod] 54 | public void TestWithDifferentKey() 55 | { 56 | IHashWithKey LIHashWithKey; 57 | 58 | string ExpectedString = ExpectedHashOfDefaultDataWithMaxUInt32AsKey; 59 | LIHashWithKey = (hash as IHashWithKey); 60 | LIHashWithKey.Key = Converters.ReadUInt32AsBytesLE(UInt32.MaxValue); 61 | 62 | string ActualString = LIHashWithKey.ComputeString(TestConstants.DefaultData, 63 | Encoding.UTF8).ToString(); 64 | 65 | Assert.AreEqual(ExpectedString, ActualString); 66 | } 67 | } 68 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Hash32/MurmurHash3_x86_32Tests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | using SharpHash.Tests; 30 | 31 | namespace SharpHash.Hash32.Tests 32 | { 33 | [TestClass] 34 | public class MurmurHash3_x86_32Tests : HashWithUInt32AsKeyBaseTests 35 | { 36 | public MurmurHash3_x86_32Tests() 37 | { 38 | hash = HashFactory.Hash32.CreateMurmurHash3_x86_32(); 39 | 40 | ExpectedHashOfEmptyData = "00000000"; 41 | ExpectedHashOfDefaultData = "3D97B9EB"; 42 | ExpectedHashOfRandomString = "A8D02B9A"; 43 | ExpectedHashOfZerotoFour = "19D02170"; 44 | ExpectedHashOfEmptyDataWithOneAsKey = "514E28B7"; 45 | ExpectedHashOfDefaultDataWithMaxUInt32AsKey = "B05606FE"; 46 | } 47 | 48 | [TestMethod] 49 | new public void TestRandomString() 50 | { 51 | TestHelper.TestActualAndExpectedData(TestConstants.RandomStringRecord, 52 | ExpectedHashOfRandomString, hash); 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Hash32/OneAtTimeTests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Hash32.Tests 31 | { 32 | [TestClass] 33 | public class OneAtTimeTests : HashAdapter1BaseTests 34 | { 35 | public OneAtTimeTests() 36 | { 37 | hash = HashFactory.Hash32.CreateOneAtTime(); 38 | 39 | ExpectedHashOfEmptyData = "00000000"; 40 | ExpectedHashOfDefaultData = "4E379A4F"; 41 | ExpectedHashOfOnetoNine = "C66B58C5"; 42 | ExpectedHashOfabcde = "B98559FC"; 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Hash32/PJWTests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Hash32.Tests 31 | { 32 | [TestClass] 33 | public class PJWTests : HashAdapter1BaseTests 34 | { 35 | public PJWTests() 36 | { 37 | hash = HashFactory.Hash32.CreatePJW(); 38 | 39 | ExpectedHashOfEmptyData = "00000000"; 40 | ExpectedHashOfDefaultData = "01F5B2CC"; 41 | ExpectedHashOfOnetoNine = "0678AEE9"; 42 | ExpectedHashOfabcde = "006789A5"; 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Hash32/RSTests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Hash32.Tests 31 | { 32 | [TestClass] 33 | public class RSTests : HashAdapter1BaseTests 34 | { 35 | public RSTests() 36 | { 37 | hash = HashFactory.Hash32.CreateRS(); 38 | 39 | ExpectedHashOfEmptyData = "00000000"; 40 | ExpectedHashOfDefaultData = "9EF98E63"; 41 | ExpectedHashOfOnetoNine = "704952E9"; 42 | ExpectedHashOfabcde = "A4A13F5D"; 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Hash32/RotatingTests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Hash32.Tests 31 | { 32 | [TestClass] 33 | public class RotatingTests : HashAdapter1BaseTests 34 | { 35 | public RotatingTests() 36 | { 37 | hash = HashFactory.Hash32.CreateRotating(); 38 | 39 | ExpectedHashOfEmptyData = "00000000"; 40 | ExpectedHashOfDefaultData = "158009D3"; 41 | ExpectedHashOfOnetoNine = "1076548B"; 42 | ExpectedHashOfabcde = "00674525"; 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Hash32/SDBMTests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Hash32.Tests 31 | { 32 | [TestClass] 33 | public class SDBMTests : HashAdapter1BaseTests 34 | { 35 | public SDBMTests() 36 | { 37 | hash = HashFactory.Hash32.CreateSDBM(); 38 | 39 | ExpectedHashOfEmptyData = "00000000"; 40 | ExpectedHashOfDefaultData = "3001A5C9"; 41 | ExpectedHashOfOnetoNine = "68A07035"; 42 | ExpectedHashOfabcde = "BD500063"; 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Hash32/ShiftAndXorTests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Hash32.Tests 31 | { 32 | [TestClass] 33 | public class ShiftAndXorTests : HashAdapter1BaseTests 34 | { 35 | public ShiftAndXorTests() 36 | { 37 | hash = HashFactory.Hash32.CreateShiftAndXor(); 38 | 39 | ExpectedHashOfEmptyData = "00000000"; 40 | ExpectedHashOfDefaultData = "BD0A7DA4"; 41 | ExpectedHashOfOnetoNine = "E164F745"; 42 | ExpectedHashOfabcde = "0731B823"; 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Hash32/SuperFastTests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Hash32.Tests 31 | { 32 | [TestClass] 33 | public class SuperFastTests : HashAdapter1BaseTests 34 | { 35 | public SuperFastTests() 36 | { 37 | hash = HashFactory.Hash32.CreateSuperFast(); 38 | 39 | ExpectedHashOfEmptyData = "00000000"; 40 | ExpectedHashOfDefaultData = "F00EB3C0"; 41 | ExpectedHashOfOnetoNine = "9575A2E9"; 42 | ExpectedHashOfabcde = "51ED072E"; 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Hash32/XXHash32Tests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Hash32.Tests 31 | { 32 | [TestClass] 33 | public class XXHash32Tests : HashWithUInt32AsKeyBaseTests 34 | { 35 | public XXHash32Tests() 36 | { 37 | hash = HashFactory.Hash32.CreateXXHash32(); 38 | 39 | ExpectedHashOfEmptyData = "02CC5D05"; 40 | ExpectedHashOfDefaultData = "6A1C7A99"; 41 | ExpectedHashOfRandomString = "CE8CF448"; 42 | ExpectedHashOfZerotoFour = "8AA3B71C"; 43 | ExpectedHashOfEmptyDataWithOneAsKey = "0B2CB792"; 44 | ExpectedHashOfDefaultDataWithMaxUInt32AsKey = "728C6772"; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Hash64/FNV1a64Tests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Hash64.Tests 31 | { 32 | [TestClass] 33 | public class FNV1a64Tests : HashAdapter1BaseTests 34 | { 35 | public FNV1a64Tests() 36 | { 37 | hash = HashFactory.Hash64.CreateFNV1a(); 38 | 39 | ExpectedHashOfEmptyData = "CBF29CE484222325"; 40 | ExpectedHashOfDefaultData = "5997E22BF92B0598"; 41 | ExpectedHashOfOnetoNine = "06D5573923C6CDFC"; 42 | ExpectedHashOfabcde = "6348C52D762364A8"; 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Hash64/FNV64Tests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Hash64.Tests 31 | { 32 | [TestClass] 33 | public class FNV64Tests : HashAdapter1BaseTests 34 | { 35 | public FNV64Tests() 36 | { 37 | hash = HashFactory.Hash64.CreateFNV(); 38 | 39 | ExpectedHashOfEmptyData = "0000000000000000"; 40 | ExpectedHashOfDefaultData = "061A6856F5925B83"; 41 | ExpectedHashOfOnetoNine = "B8FB573C21FE68F1"; 42 | ExpectedHashOfabcde = "77018B280326F529"; 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /SharpHash.Tests/Hash64/XXHash64Tests.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting; 28 | using SharpHash.Base; 29 | 30 | namespace SharpHash.Hash64.Tests 31 | { 32 | [TestClass] 33 | public class XXHash64Tests : HashWithUInt64AsKeyBaseTests 34 | { 35 | public XXHash64Tests() 36 | { 37 | hash = HashFactory.Hash64.CreateXXHash64(); 38 | 39 | ExpectedHashOfEmptyData = "EF46DB3751D8E999"; 40 | ExpectedHashOfDefaultData = "0F1FADEDD0B77861"; 41 | ExpectedHashOfRandomString = "C9C17BCD07584404"; 42 | ExpectedHashOfZerotoFour = "34CB4C2EE6166F65"; 43 | ExpectedHashOfEmptyDataWithOneAsKey = "D5AFBA1336A3BE4B"; 44 | ExpectedHashOfDefaultDataWithMaxUInt64AsKey = "68DCC1056096A94F"; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /SharpHash.Tests/SharpHash.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netcoreapp2.0 5 | 6 | false 7 | 8 | 9 | 10 | Library 11 | 12 | 13 | 14 | true 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /SharpHash.Tests/default_data.txt: -------------------------------------------------------------------------------- 1 | HashLib4Pascal -------------------------------------------------------------------------------- /SharpHash/Base/HashRounds.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | namespace SharpHash.Base 28 | { 29 | public enum HashRounds 30 | { 31 | Rounds3 = 3, 32 | Rounds4 = 4, 33 | Rounds5 = 5, 34 | Rounds8 = 8 35 | } 36 | } -------------------------------------------------------------------------------- /SharpHash/Base/HashSize.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | namespace SharpHash.Base 28 | { 29 | // Note: The name HashSizeEnum was given considering the name conflict 30 | // between the enum and the Hash property for getting hash_size. 31 | public enum HashSizeEnum 32 | { 33 | HashSize128 = 16, 34 | HashSize160 = 20, 35 | HashSize192 = 24, 36 | HashSize224 = 28, 37 | HashSize256 = 32, 38 | HashSize288 = 36, 39 | HashSize384 = 48, 40 | HashSize512 = 64 41 | } 42 | } -------------------------------------------------------------------------------- /SharpHash/Crypto/Blake2BConfigurations/Blake2XBConfig.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using SharpHash.Interfaces.IBlake2BConfigurations; 28 | 29 | namespace SharpHash.Crypto.Blake2BConfigurations 30 | { 31 | /// 32 | /// Blake2XBConfig is used to configure hash function parameters and 33 | /// keying. 34 | /// 35 | public sealed class Blake2XBConfig : IBlake2XBConfig 36 | { 37 | public IBlake2BConfig Blake2BConfig { get; set; } = null; // blake2B config object 38 | public IBlake2BTreeConfig Blake2BTreeConfig { get; set; } = null; // blake2B tree config object 39 | 40 | public Blake2XBConfig(IBlake2BConfig a_Blake2BConfig = null, IBlake2BTreeConfig a_Blake2BTreeConfig = null) 41 | { 42 | 43 | Blake2BConfig = a_Blake2BConfig; 44 | Blake2BTreeConfig = a_Blake2BTreeConfig; 45 | } // end cctr 46 | 47 | public IBlake2XBConfig Clone() 48 | { 49 | return new Blake2XBConfig(Blake2BConfig?.Clone(), Blake2BTreeConfig?.Clone()); 50 | } // end funtion Clone 51 | 52 | } // end class Blake2XBConfig 53 | 54 | } 55 | -------------------------------------------------------------------------------- /SharpHash/Crypto/Blake2SConfigurations/Blake2XSConfig.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using SharpHash.Interfaces.IBlake2SConfigurations; 28 | 29 | namespace SharpHash.Crypto.Blake2SConfigurations 30 | { 31 | /// 32 | /// Blake2XSConfig is used to configure hash function parameters and 33 | /// keying. 34 | /// 35 | public sealed class Blake2XSConfig : IBlake2XSConfig 36 | { 37 | public IBlake2SConfig Blake2SConfig { get; set; } = null; // blake2S config object 38 | public IBlake2STreeConfig Blake2STreeConfig { get; set; } = null; // blake2S tree config object 39 | 40 | public Blake2XSConfig(IBlake2SConfig a_Blake2SConfig = null, IBlake2STreeConfig a_Blake2STreeConfig = null) 41 | { 42 | Blake2SConfig = a_Blake2SConfig; 43 | Blake2STreeConfig = a_Blake2STreeConfig; 44 | } // end cctr 45 | 46 | public IBlake2XSConfig Clone() 47 | { 48 | return new Blake2XSConfig(Blake2SConfig?.Clone(), Blake2STreeConfig?.Clone()); 49 | } // end funtion Clone 50 | 51 | } // end class Blake2XSConfig 52 | 53 | } 54 | -------------------------------------------------------------------------------- /SharpHash/Hash32/Bernstein.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using SharpHash.Base; 28 | using SharpHash.Interfaces; 29 | using System; 30 | 31 | namespace SharpHash.Hash32 32 | { 33 | internal sealed class Bernstein : Hash, IHash32, ITransformBlock 34 | { 35 | private UInt32 hash; 36 | 37 | public Bernstein() 38 | : base(4, 1) 39 | { } // end constructor 40 | 41 | override public IHash Clone() 42 | { 43 | Bernstein HashInstance = new Bernstein(); 44 | HashInstance.hash = hash; 45 | 46 | HashInstance.BufferSize = BufferSize; 47 | 48 | return HashInstance; 49 | } // end function Clone 50 | 51 | override public void Initialize() 52 | { 53 | hash = 5381; 54 | } // end function Initialize 55 | 56 | override public IHashResult TransformFinal() 57 | { 58 | IHashResult result = new HashResult(hash); 59 | 60 | Initialize(); 61 | 62 | return result; 63 | } // end function TransformFinal 64 | 65 | override public void TransformBytes(byte[] a_data, Int32 a_index, Int32 a_length) 66 | { 67 | Int32 i = a_index; 68 | 69 | while (a_length > 0) 70 | { 71 | hash = (hash * 33) + a_data[i]; 72 | i++; 73 | a_length--; 74 | } // end while 75 | } // end function TransformBytes 76 | } // end class Bernstein 77 | } -------------------------------------------------------------------------------- /SharpHash/Hash32/Bernstein1.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using SharpHash.Base; 28 | using SharpHash.Interfaces; 29 | using System; 30 | 31 | namespace SharpHash.Hash32 32 | { 33 | internal sealed class Bernstein1 : Hash, IHash32, ITransformBlock 34 | { 35 | private UInt32 hash; 36 | 37 | public Bernstein1() 38 | : base(4, 1) 39 | { } // end constructor 40 | 41 | override public IHash Clone() 42 | { 43 | Bernstein1 HashInstance = new Bernstein1(); 44 | HashInstance.hash = hash; 45 | 46 | HashInstance.BufferSize = BufferSize; 47 | 48 | return HashInstance; 49 | } // end function Clone 50 | 51 | override public void Initialize() 52 | { 53 | hash = 5381; 54 | } // end function Initialize 55 | 56 | override public IHashResult TransformFinal() 57 | { 58 | IHashResult result = new HashResult(hash); 59 | 60 | Initialize(); 61 | 62 | return result; 63 | } // end function TransformFinal 64 | 65 | override public void TransformBytes(byte[] a_data, Int32 a_index, Int32 a_length) 66 | { 67 | Int32 i = a_index; 68 | 69 | while (a_length > 0) 70 | { 71 | hash = (hash * 33) ^ a_data[i]; 72 | i++; 73 | a_length--; 74 | } // end while 75 | } // end function TransformBytes 76 | } // end class Bernstein1 77 | } -------------------------------------------------------------------------------- /SharpHash/Hash32/DEK.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using SharpHash.Base; 28 | using SharpHash.Utils; 29 | using SharpHash.Interfaces; 30 | using System; 31 | using System.IO; 32 | 33 | namespace SharpHash.Hash32 34 | { 35 | internal sealed class DEK : MultipleTransformNonBlock, IHash32, ITransformBlock 36 | { 37 | public DEK() 38 | : base(4, 1) 39 | { } // end constructor 40 | 41 | override public IHash Clone() 42 | { 43 | DEK HashInstance = new DEK(); 44 | 45 | HashInstance.Buffer = new MemoryStream(); 46 | byte[] buf = Buffer.ToArray(); 47 | HashInstance.Buffer.Write(buf, 0, buf.Length); 48 | HashInstance.Buffer.Position = Buffer.Position; 49 | 50 | HashInstance.BufferSize = BufferSize; 51 | 52 | return HashInstance; 53 | } // end function Clone 54 | 55 | override protected IHashResult ComputeAggregatedBytes(byte[] a_data) 56 | { 57 | UInt32 hash = 0; 58 | 59 | if (!a_data.Empty()) 60 | { 61 | hash = (UInt32)a_data.Length; 62 | 63 | for (Int32 i = 0; i < a_data.Length; i++) 64 | hash = Utils.Bits.RotateLeft32(hash, 5) ^ a_data[i]; 65 | } // end if 66 | 67 | return new HashResult(hash); 68 | } // end function ComputeAggregatedBytes 69 | } // end class DEK 70 | } -------------------------------------------------------------------------------- /SharpHash/Hash32/DJB.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using SharpHash.Base; 28 | using SharpHash.Interfaces; 29 | using System; 30 | 31 | namespace SharpHash.Hash32 32 | { 33 | internal sealed class DJB : Hash, IHash32, ITransformBlock 34 | { 35 | private UInt32 hash; 36 | 37 | public DJB() 38 | : base(4, 1) 39 | { } // end constructor 40 | 41 | override public IHash Clone() 42 | { 43 | DJB HashInstance = new DJB(); 44 | HashInstance.hash = hash; 45 | 46 | HashInstance.BufferSize = BufferSize; 47 | 48 | return HashInstance; 49 | } // end function Clone 50 | 51 | override public void Initialize() 52 | { 53 | hash = 5381; 54 | } // end function Initialize 55 | 56 | override public IHashResult TransformFinal() 57 | { 58 | IHashResult result = new HashResult(hash); 59 | 60 | Initialize(); 61 | 62 | return result; 63 | } // end function TransformFinal 64 | 65 | override public void TransformBytes(byte[] a_data, Int32 a_index, Int32 a_length) 66 | { 67 | Int32 i = a_index; 68 | 69 | while (a_length > 0) 70 | { 71 | hash = ((hash << 5) + hash) + a_data[i]; 72 | i++; 73 | a_length--; 74 | } // end while 75 | } // end function TransformBytes 76 | } // end class 77 | } -------------------------------------------------------------------------------- /SharpHash/Hash32/FNV.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using SharpHash.Base; 28 | using SharpHash.Interfaces; 29 | using System; 30 | 31 | namespace SharpHash.Hash32 32 | { 33 | internal sealed class FNV : Hash, IHash32, ITransformBlock 34 | { 35 | private UInt32 hash; 36 | 37 | public FNV() 38 | : base(4, 1) 39 | { } // end constructor 40 | 41 | override public IHash Clone() 42 | { 43 | FNV HashInstance = new FNV(); 44 | HashInstance.hash = hash; 45 | 46 | HashInstance.BufferSize = BufferSize; 47 | 48 | return HashInstance; 49 | } // end function Clone 50 | 51 | override public void Initialize() 52 | { 53 | hash = 0; 54 | } // end function Initialize 55 | 56 | override public IHashResult TransformFinal() 57 | { 58 | IHashResult result = new HashResult(hash); 59 | 60 | Initialize(); 61 | 62 | return result; 63 | } // end function TransformFinal 64 | 65 | override public void TransformBytes(byte[] a_data, Int32 a_index, Int32 a_length) 66 | { 67 | Int32 i = a_index; 68 | 69 | while (a_length > 0) 70 | { 71 | hash = (hash * 16777619) ^ a_data[i]; 72 | i++; 73 | a_length--; 74 | } // end while 75 | } // end function TransformBytes 76 | } // end class FNV 77 | } -------------------------------------------------------------------------------- /SharpHash/Hash32/FNV1a.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using SharpHash.Base; 28 | using SharpHash.Interfaces; 29 | using System; 30 | 31 | namespace SharpHash.Hash32 32 | { 33 | internal sealed class FNV1a : Hash, IHash32, ITransformBlock 34 | { 35 | private UInt32 hash; 36 | 37 | public FNV1a() 38 | : base(4, 1) 39 | { } // end constructor 40 | 41 | override public IHash Clone() 42 | { 43 | FNV1a HashInstance = new FNV1a(); 44 | HashInstance.hash = hash; 45 | 46 | HashInstance.BufferSize = BufferSize; 47 | 48 | return HashInstance; 49 | } // end function Clone 50 | 51 | override public void Initialize() 52 | { 53 | hash = 2166136261; 54 | } // end function Initialize 55 | 56 | override public IHashResult TransformFinal() 57 | { 58 | IHashResult result = new HashResult(hash); 59 | 60 | Initialize(); 61 | 62 | return result; 63 | } // end function TransformFinal 64 | 65 | override public void TransformBytes(byte[] a_data, Int32 a_index, Int32 a_length) 66 | { 67 | Int32 i = a_index; 68 | 69 | while (a_length > 0) 70 | { 71 | hash = (hash ^ a_data[i]) * 16777619; 72 | i++; 73 | a_length--; 74 | } // end while 75 | } // end function TransformBytes 76 | } // end class FNV1a 77 | } -------------------------------------------------------------------------------- /SharpHash/Hash32/JS.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using SharpHash.Base; 28 | using SharpHash.Interfaces; 29 | using System; 30 | 31 | namespace SharpHash.Hash32 32 | { 33 | internal sealed class JS : Hash, IHash32, ITransformBlock 34 | { 35 | private UInt32 hash; 36 | 37 | public JS() 38 | : base(4, 1) 39 | { } // end constructor 40 | 41 | override public IHash Clone() 42 | { 43 | JS HashInstance = new JS(); 44 | HashInstance.hash = hash; 45 | 46 | HashInstance.BufferSize = BufferSize; 47 | 48 | return HashInstance; 49 | } // end function Clone 50 | 51 | override public void Initialize() 52 | { 53 | hash = 1315423911; 54 | } // end function Initialize 55 | 56 | override public IHashResult TransformFinal() 57 | { 58 | IHashResult result = new HashResult(hash); 59 | 60 | Initialize(); 61 | 62 | return result; 63 | } // end function TransformFinal 64 | 65 | override public void TransformBytes(byte[] a_data, Int32 a_index, Int32 a_length) 66 | { 67 | Int32 i = a_index; 68 | 69 | while (a_length > 0) 70 | { 71 | hash = hash ^ ((hash << 5) + a_data[i] + (hash >> 2)); 72 | i++; 73 | a_length--; 74 | } // end while 75 | } // end function TransformBytes 76 | } // end class JS 77 | } -------------------------------------------------------------------------------- /SharpHash/Hash32/Rotating.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using SharpHash.Base; 28 | using SharpHash.Interfaces; 29 | using System; 30 | 31 | namespace SharpHash.Hash32 32 | { 33 | internal sealed class Rotating : Hash, IHash32, ITransformBlock 34 | { 35 | private UInt32 hash; 36 | 37 | public Rotating() 38 | : base(4, 1) 39 | { } // end constructor 40 | 41 | override public IHash Clone() 42 | { 43 | Rotating HashInstance = new Rotating(); 44 | HashInstance.hash = hash; 45 | 46 | HashInstance.BufferSize = BufferSize; 47 | 48 | return HashInstance; 49 | } // end function Clone 50 | 51 | override public void Initialize() 52 | { 53 | hash = 0; 54 | } // end function Initialize 55 | 56 | override public IHashResult TransformFinal() 57 | { 58 | IHashResult result = new HashResult(hash); 59 | 60 | Initialize(); 61 | 62 | return result; 63 | } // end function TransformFinal 64 | 65 | override public void TransformBytes(byte[] a_data, Int32 a_index, Int32 a_length) 66 | { 67 | Int32 i = a_index; 68 | 69 | while (a_length > 0) 70 | { 71 | hash = Utils.Bits.RotateLeft32(hash, 4) ^ a_data[i]; 72 | i++; 73 | a_length--; 74 | } // end while 75 | } // end function TransformBytes 76 | } // end class Rotating 77 | } -------------------------------------------------------------------------------- /SharpHash/Hash32/SDBM.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using SharpHash.Base; 28 | using SharpHash.Interfaces; 29 | using System; 30 | 31 | namespace SharpHash.Hash32 32 | { 33 | internal sealed class SDBM : Hash, IHash32, ITransformBlock 34 | { 35 | private UInt32 hash; 36 | 37 | public SDBM() 38 | : base(4, 1) 39 | { } // end constructor 40 | 41 | override public IHash Clone() 42 | { 43 | SDBM HashInstance = new SDBM(); 44 | HashInstance.hash = hash; 45 | 46 | HashInstance.BufferSize = BufferSize; 47 | 48 | return HashInstance; 49 | } // end function Clone 50 | 51 | override public void Initialize() 52 | { 53 | hash = 0; 54 | } // end function Initialize 55 | 56 | override public IHashResult TransformFinal() 57 | { 58 | IHashResult result = new HashResult(hash); 59 | 60 | Initialize(); 61 | 62 | return result; 63 | } // end function TransformFinal 64 | 65 | override public void TransformBytes(byte[] a_data, Int32 a_index, Int32 a_length) 66 | { 67 | Int32 i = a_index; 68 | 69 | while (a_length > 0) 70 | { 71 | hash = (UInt32)(a_data[i] + (Int64)(hash << 6) + (Int64)(hash << 16) - hash); 72 | i++; 73 | a_length--; 74 | } // end while 75 | } // end function TransformBytes 76 | } // end class SDBM 77 | } -------------------------------------------------------------------------------- /SharpHash/Hash32/ShiftAndXor.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using SharpHash.Base; 28 | using SharpHash.Interfaces; 29 | using System; 30 | 31 | namespace SharpHash.Hash32 32 | { 33 | internal sealed class ShiftAndXor : Hash, IHash32, ITransformBlock 34 | { 35 | private UInt32 hash; 36 | 37 | public ShiftAndXor() 38 | : base(4, 1) 39 | { } // end constructor 40 | 41 | override public IHash Clone() 42 | { 43 | ShiftAndXor HashInstance = new ShiftAndXor(); 44 | HashInstance.hash = hash; 45 | 46 | HashInstance.BufferSize = BufferSize; 47 | 48 | return HashInstance; 49 | } // end function Clone 50 | 51 | override public void Initialize() 52 | { 53 | hash = 0; 54 | } // end function Initialize 55 | 56 | override public IHashResult TransformFinal() 57 | { 58 | IHashResult result = new HashResult(hash); 59 | 60 | Initialize(); 61 | 62 | return result; 63 | } // end function TransformFinal 64 | 65 | override public void TransformBytes(byte[] a_data, Int32 a_index, Int32 a_length) 66 | { 67 | Int32 i = a_index; 68 | 69 | while (a_length > 0) 70 | { 71 | hash = hash ^ ((hash << 5) + (hash >> 2) + a_data[i]); 72 | i++; 73 | a_length--; 74 | } // end while 75 | } // end function TransformBytes 76 | } // end class ShiftAndXor 77 | } -------------------------------------------------------------------------------- /SharpHash/Hash64/FNV1a64.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using SharpHash.Base; 28 | using SharpHash.Interfaces; 29 | using System; 30 | 31 | namespace SharpHash.Hash64 32 | { 33 | internal sealed class FNV1a64 : Hash, IHash64, ITransformBlock 34 | { 35 | private UInt64 hash; 36 | 37 | public FNV1a64() 38 | : base(8, 1) 39 | { } // end constructor 40 | 41 | override public IHash Clone() 42 | { 43 | FNV1a64 HashInstance = new FNV1a64(); 44 | HashInstance.hash = hash; 45 | 46 | HashInstance.BufferSize = BufferSize; 47 | 48 | return HashInstance; 49 | } // end function Clone 50 | 51 | override public void Initialize() 52 | { 53 | hash = 14695981039346656037; 54 | } // end function Initialize 55 | 56 | override public IHashResult TransformFinal() 57 | { 58 | IHashResult result = new HashResult(hash); 59 | 60 | Initialize(); 61 | 62 | return result; 63 | } // end function TransformFinal 64 | 65 | override public void TransformBytes(byte[] a_data, Int32 a_index, Int32 a_length) 66 | { 67 | Int32 i = a_index; 68 | 69 | while (a_length > 0) 70 | { 71 | hash = (hash ^ a_data[i]) * 1099511628211; 72 | i++; 73 | a_length--; 74 | } // end while 75 | } // end function TransformBytes 76 | } // end class FNV1a64 77 | } -------------------------------------------------------------------------------- /SharpHash/Hash64/FNV64.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using SharpHash.Base; 28 | using SharpHash.Interfaces; 29 | using System; 30 | 31 | namespace SharpHash.Hash64 32 | { 33 | internal sealed class FNV64 : Hash, IHash64, ITransformBlock 34 | { 35 | private UInt64 hash; 36 | 37 | public FNV64() 38 | : base(8, 1) 39 | { } // end constructor 40 | 41 | override public IHash Clone() 42 | { 43 | FNV64 HashInstance = new FNV64(); 44 | HashInstance.hash = hash; 45 | 46 | HashInstance.BufferSize = BufferSize; 47 | 48 | return HashInstance; 49 | } // end function Clone 50 | 51 | override public void Initialize() 52 | { 53 | hash = 0; 54 | } // end function Initialize 55 | 56 | override public IHashResult TransformFinal() 57 | { 58 | IHashResult result = new HashResult(hash); 59 | 60 | Initialize(); 61 | 62 | return result; 63 | } // end function TransformFinal 64 | 65 | override public void TransformBytes(byte[] a_data, Int32 a_index, Int32 a_length) 66 | { 67 | Int32 i = a_index; 68 | 69 | while (a_length > 0) 70 | { 71 | hash = (hash * 1099511628211) ^ a_data[i]; 72 | i++; 73 | a_length--; 74 | } // end while 75 | } // end function TransformBytes 76 | } // end class FNV64 77 | } -------------------------------------------------------------------------------- /SharpHash/Interfaces/IBlake2BConfigurations/IBlake2BConfig.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using System; 28 | 29 | namespace SharpHash.Interfaces.IBlake2BConfigurations 30 | { 31 | public interface IBlake2BConfig 32 | { 33 | byte[] Personalisation { get; set; } 34 | byte[] Salt { get; set; } 35 | byte[] Key { get; set; } 36 | Int32 HashSize { get; set; } 37 | 38 | IBlake2BConfig Clone(); 39 | 40 | void Clear(); 41 | 42 | } // end interface IBlake2BConfig 43 | } -------------------------------------------------------------------------------- /SharpHash/Interfaces/IBlake2BConfigurations/IBlake2BTreeConfig.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using System; 28 | 29 | namespace SharpHash.Interfaces.IBlake2BConfigurations 30 | { 31 | public interface IBlake2BTreeConfig 32 | { 33 | byte FanOut { get; set; } 34 | byte MaxDepth { get; set; } 35 | byte NodeDepth { get; set; } 36 | byte InnerHashSize { get; set; } 37 | UInt32 LeafSize { get; set; } 38 | UInt64 NodeOffset { get; set; } 39 | bool IsLastNode { get; set; } 40 | 41 | IBlake2BTreeConfig Clone(); 42 | 43 | } // end interface IBlake2BTreeConfig 44 | } -------------------------------------------------------------------------------- /SharpHash/Interfaces/IBlake2BConfigurations/IBlake2XBConfig.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | namespace SharpHash.Interfaces.IBlake2BConfigurations 28 | { 29 | public interface IBlake2XBConfig 30 | { 31 | IBlake2BConfig Blake2BConfig { get; set; } 32 | IBlake2BTreeConfig Blake2BTreeConfig { get; set; } 33 | 34 | IBlake2XBConfig Clone(); 35 | } // end interface IBlake2XSConfig 36 | } 37 | -------------------------------------------------------------------------------- /SharpHash/Interfaces/IBlake2SConfigurations/IBlake2SConfig.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using System; 28 | 29 | namespace SharpHash.Interfaces.IBlake2SConfigurations 30 | { 31 | public interface IBlake2SConfig 32 | { 33 | byte[] Personalisation { get; set; } 34 | byte[] Salt { get; set; } 35 | byte[] Key { get; set; } 36 | Int32 HashSize { get; set; } 37 | 38 | IBlake2SConfig Clone(); 39 | 40 | void Clear(); 41 | 42 | } // end interface IBlake2SConfig 43 | } -------------------------------------------------------------------------------- /SharpHash/Interfaces/IBlake2SConfigurations/IBlake2STreeConfig.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using System; 28 | 29 | namespace SharpHash.Interfaces.IBlake2SConfigurations 30 | { 31 | public interface IBlake2STreeConfig 32 | { 33 | byte FanOut { get; set; } 34 | byte MaxDepth { get; set; } 35 | byte NodeDepth { get; set; } 36 | byte InnerHashSize { get; set; } 37 | UInt32 LeafSize { get; set; } 38 | UInt64 NodeOffset { get; set; } 39 | bool IsLastNode { get; set; } 40 | 41 | IBlake2STreeConfig Clone(); 42 | 43 | } // end interface IBlake2STreeConfig 44 | } -------------------------------------------------------------------------------- /SharpHash/Interfaces/IBlake2SConfigurations/IBlake2XSConfig.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using System; 28 | 29 | namespace SharpHash.Interfaces.IBlake2SConfigurations 30 | { 31 | public interface IBlake2XSConfig 32 | { 33 | IBlake2SConfig Blake2SConfig { get; set; } 34 | IBlake2STreeConfig Blake2STreeConfig { get; set; } 35 | 36 | IBlake2XSConfig Clone(); 37 | } // end interface IBlake2XSConfig 38 | } 39 | -------------------------------------------------------------------------------- /SharpHash/Interfaces/ICRC.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using System; 28 | 29 | namespace SharpHash.Interfaces 30 | { 31 | public interface ICRC : IHash 32 | { 33 | string[] Names { get; } 34 | Int32 Width { get; } 35 | UInt64 Polynomial { get; } 36 | UInt64 Initial { get; } 37 | bool IsInputReflected { get; } 38 | bool IsOutputReflected { get; } 39 | UInt64 OutputXor { get; } 40 | UInt64 CheckValue { get; } 41 | } 42 | } -------------------------------------------------------------------------------- /SharpHash/Interfaces/IHash.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using System; 28 | using System.IO; 29 | using System.Text; 30 | 31 | namespace SharpHash.Interfaces 32 | { 33 | public interface IHash 34 | { 35 | string Name { get; } 36 | Int32 BlockSize { get; } 37 | Int32 HashSize { get; } 38 | Int32 BufferSize { get; set; } 39 | 40 | IHash Clone(); 41 | 42 | IHashResult ComputeString(string a_data, Encoding encoding); 43 | 44 | IHashResult ComputeBytes(byte[] a_data); 45 | 46 | IHashResult ComputeUntyped(IntPtr a_data, Int64 a_length); 47 | 48 | IHashResult ComputeStream(Stream a_stream, Int64 a_length = -1); 49 | 50 | IHashResult ComputeFile(string a_file_name, Int64 a_from = 0, Int64 a_length = -1); 51 | 52 | void Initialize(); 53 | 54 | void TransformBytes(byte[] a_data, Int32 a_index, Int32 a_length); 55 | 56 | void TransformBytes(byte[] a_data, Int32 a_index); 57 | 58 | void TransformBytes(byte[] a_data); 59 | 60 | void TransformUntyped(IntPtr a_data, Int64 a_length); 61 | 62 | IHashResult TransformFinal(); 63 | 64 | void TransformString(string a_data, Encoding encoding); 65 | 66 | void TransformStream(Stream a_stream, Int64 a_length = -1); 67 | 68 | void TransformFile(string a_file_name, Int64 a_from = 0, Int64 a_length = -1); 69 | } 70 | } -------------------------------------------------------------------------------- /SharpHash/Interfaces/IHashResult.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using System; 28 | 29 | namespace SharpHash.Interfaces 30 | { 31 | public interface IHashResult 32 | { 33 | byte[] GetBytes(); 34 | 35 | byte GetUInt8(); 36 | 37 | UInt16 GetUInt16(); 38 | 39 | UInt32 GetUInt32(); 40 | 41 | Int32 GetInt32(); 42 | 43 | UInt64 GetUInt64(); 44 | 45 | string ToString(bool a_group = false); 46 | 47 | Int32 GetHashCode(); 48 | 49 | bool CompareTo(IHashResult a_hashResult); 50 | } 51 | } -------------------------------------------------------------------------------- /SharpHash/Interfaces/IKDF.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using System; 28 | 29 | namespace SharpHash.Interfaces 30 | { 31 | public interface IKDF 32 | { 33 | string Name { get; } 34 | 35 | string ToString(); 36 | 37 | void Clear(); 38 | 39 | /// 40 | /// Returns the pseudo-random bytes for this object. 41 | /// 42 | /// The number of pseudo-random key bytes to generate. 43 | /// A byte array filled with pseudo-random key bytes. 44 | /// bc must be greater than zero. 45 | /// invalid start index or end index of internal buffer. 46 | byte[] GetBytes(Int32 bc); 47 | } // end interface IKDF 48 | 49 | public interface IKDFNotBuiltIn : IKDF 50 | { 51 | IKDFNotBuiltIn Clone(); 52 | } // end interface IKDFNotBuiltIn 53 | 54 | } -------------------------------------------------------------------------------- /SharpHash/KDF/Argon2TypeAndVersion.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | namespace SharpHash.KDF 28 | { 29 | public enum Argon2Type 30 | { 31 | a2tARGON2_d = 0x00, a2tARGON2_i = 0x01, a2tARGON2_id = 0x02 32 | } // end enum IArgon2Type 33 | 34 | public enum Argon2Version 35 | { 36 | a2vARGON2_VERSION_10 = 0x10, a2vARGON2_VERSION_13 = 0x13 37 | } // end enum IArgon2Version 38 | } -------------------------------------------------------------------------------- /SharpHash/KDF/KDFNotBuiltIn.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using SharpHash.Interfaces; 28 | using System; 29 | 30 | namespace SharpHash.KDF 31 | { 32 | internal abstract class KDFNotBuiltIn : IKDFNotBuiltIn 33 | { 34 | 35 | public abstract string Name { get; } 36 | 37 | public abstract override string ToString(); 38 | 39 | public abstract IKDFNotBuiltIn Clone(); 40 | 41 | public abstract void Clear(); 42 | 43 | /// 44 | /// Returns the pseudo-random bytes for this object. 45 | /// 46 | /// The number of pseudo-random key bytes to generate. 47 | /// A byte array filled with pseudo-random key bytes. 48 | /// bc must be greater than zero. 49 | /// invalid start index or end index of internal buffer. 50 | public abstract byte[] GetBytes(Int32 bc); 51 | } 52 | } -------------------------------------------------------------------------------- /SharpHash/SharpHash.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Library 5 | netcoreapp2.0 6 | true 7 | 8 | 9 | Ron4fun, Xor-el, IzarchTech 10 | XorelConcepts 11 | true 12 | SharpHash is a C# hashing library which provides an easy to use interface for computing hashes and checksums of data. It also supports state based (incremental) hashing. 13 | LICENSE 14 | https://github.com/ron4fun/SharpHash 15 | https://github.com/ron4fun/SharpHash.git 16 | 2022 17 | SharpHash 18 | Hash;Hashing;Crypto;Cryptography;Checksum;HMAC;KDF;PBKDF; 19 | git 20 | true 21 | false 22 | false 23 | sharphash_key.pfx 24 | 1.2.0 25 | 26 | 27 | 28 | false 29 | 30 | 31 | 32 | 33 | True 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /SharpHash/SharpHash.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.29306.81 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SharpHash", "SharpHash.csproj", "{E09A2FF7-FB5E-48E7-94DD-27C15154FD0D}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SharpHash.Tests", "..\SharpHash.Tests\SharpHash.Tests.csproj", "{2C3D354C-E1DA-49EF-A506-415DCE29B31F}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpHash.PerformanceBenchmark", "..\SharpHash.PerformanceBenchmark\SharpHash.PerformanceBenchmark.csproj", "{A68AA212-9578-40EA-B1C7-92A91A1E9CCF}" 11 | EndProject 12 | Global 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Debug|Any CPU = Debug|Any CPU 15 | Release|Any CPU = Release|Any CPU 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {E09A2FF7-FB5E-48E7-94DD-27C15154FD0D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 19 | {E09A2FF7-FB5E-48E7-94DD-27C15154FD0D}.Debug|Any CPU.Build.0 = Debug|Any CPU 20 | {E09A2FF7-FB5E-48E7-94DD-27C15154FD0D}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {E09A2FF7-FB5E-48E7-94DD-27C15154FD0D}.Release|Any CPU.Build.0 = Release|Any CPU 22 | {2C3D354C-E1DA-49EF-A506-415DCE29B31F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 23 | {2C3D354C-E1DA-49EF-A506-415DCE29B31F}.Debug|Any CPU.Build.0 = Debug|Any CPU 24 | {2C3D354C-E1DA-49EF-A506-415DCE29B31F}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {2C3D354C-E1DA-49EF-A506-415DCE29B31F}.Release|Any CPU.Build.0 = Release|Any CPU 26 | {A68AA212-9578-40EA-B1C7-92A91A1E9CCF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 27 | {A68AA212-9578-40EA-B1C7-92A91A1E9CCF}.Debug|Any CPU.Build.0 = Debug|Any CPU 28 | {A68AA212-9578-40EA-B1C7-92A91A1E9CCF}.Release|Any CPU.ActiveCfg = Release|Any CPU 29 | {A68AA212-9578-40EA-B1C7-92A91A1E9CCF}.Release|Any CPU.Build.0 = Release|Any CPU 30 | EndGlobalSection 31 | GlobalSection(SolutionProperties) = preSolution 32 | HideSolutionNode = FALSE 33 | EndGlobalSection 34 | GlobalSection(ExtensibilityGlobals) = postSolution 35 | SolutionGuid = {427BBA11-D448-4FD5-8564-ABA8E0DF3DED} 36 | EndGlobalSection 37 | EndGlobal 38 | -------------------------------------------------------------------------------- /SharpHash/Utils/ExtendedBitConverter.cs: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | /// SharpHash Library 3 | /// Copyright(c) 2019 - 2020 Mbadiwe Nnaemeka Ronald 4 | /// Github Repository 5 | /// 6 | /// The contents of this file are subject to the 7 | /// Mozilla Public License Version 2.0 (the "License"); 8 | /// you may not use this file except in 9 | /// compliance with the License. You may obtain a copy of the License 10 | /// at https://www.mozilla.org/en-US/MPL/2.0/ 11 | /// 12 | /// Software distributed under the License is distributed on an "AS IS" 13 | /// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14 | /// the License for the specific language governing rights and 15 | /// limitations under the License. 16 | /// 17 | /// Acknowledgements: 18 | /// 19 | /// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative 20 | /// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal). 21 | /// 22 | /// Also, I will like to thank Udezue Chukwunwike (https://github.com/IzarchTech) for 23 | /// his contributions to the growth and development of this library. 24 | /// 25 | //////////////////////////////////////////////////////////////////////// 26 | 27 | using System; 28 | 29 | namespace SharpHash.Utils 30 | { 31 | internal static class ExtendedBitConverter 32 | { 33 | public static char GetHexValue(Int32 i) 34 | { 35 | if (i < 10) 36 | { 37 | return (char)(i + '0'); 38 | } // end if 39 | 40 | return (char)((i - 10) + 'A'); 41 | } // end function GetHexValue 42 | 43 | public static unsafe string ToString(IntPtr value, Int32 StartIndex, Int32 Length, char delimeter = '-') 44 | { 45 | Int32 chArrayLength = Length * 3; 46 | 47 | char[] chArray = new char[chArrayLength]; 48 | 49 | Int32 Idx = 0; 50 | Int32 Index = StartIndex; 51 | while (Idx < chArrayLength) 52 | { 53 | byte b = ((byte*)value)[Index]; 54 | Index += 1; 55 | 56 | chArray[Idx] = GetHexValue(b >> 4); 57 | chArray[Idx + 1] = GetHexValue(b & 15); 58 | chArray[Idx + 2] = delimeter; 59 | 60 | Idx += 3; 61 | } // end while 62 | 63 | return new string(chArray, 0, chArrayLength - 1); 64 | } // end function ToString 65 | } // end class ExtendedBitConverter 66 | } --------------------------------------------------------------------------------