internal void GeneratingTextHash(string hashName) { HashAlgorithm alghorithm; switch (hashName) { case "SHA1": alghorithm = new HashFunctions.SHA1(); HashingText(hashName, alghorithm); break; case "SHA224": alghorithm = new SHA2Managed(224); HashingText(hashName, alghorithm); break; case "SHA256": alghorithm = new SHA2Managed(256); HashingText(hashName, alghorithm); break; case "SHA384": alghorithm = new SHA2Managed(384); HashingText(hashName, alghorithm); break; case "SHA512": alghorithm = new SHA2Managed(512); HashingText(hashName, alghorithm); break; case "SHA3-224": alghorithm = new SHA3(224); HashingText(hashName, alghorithm); break; case "SHA3-256": alghorithm = new SHA3(256); HashingText(hashName, alghorithm); break; case "SHA3-384": alghorithm = new SHA3(384); HashingText(hashName, alghorithm); break; case "SHA3-512": alghorithm = new SHA3(512); HashingText(hashName, alghorithm); break; } }
internal void AvalancheTestOfHashFunctions(string hashName) { HashAlgorithm alghorithm; switch (hashName) { case "SHA1": alghorithm = new HashFunctions.SHA1(); CreateAvalancheBitmapAtRuntime(hashName, alghorithm); break; case "SHA224": alghorithm = new SHA2Managed(224); CreateAvalancheBitmapAtRuntime(hashName, alghorithm); break; case "SHA256": alghorithm = new SHA2Managed(256); CreateAvalancheBitmapAtRuntime(hashName, alghorithm); break; case "SHA384": alghorithm = new SHA2Managed(384); CreateAvalancheBitmapAtRuntime(hashName, alghorithm); break; case "SHA512": alghorithm = new SHA2Managed(512); CreateAvalancheBitmapAtRuntime(hashName, alghorithm); break; case "SHA3-224": alghorithm = new SHA3(224); CreateAvalancheBitmapAtRuntime(hashName, alghorithm); break; case "SHA3-256": alghorithm = new SHA3(256); CreateAvalancheBitmapAtRuntime(hashName, alghorithm); break; case "SHA3-384": alghorithm = new SHA3(384); CreateAvalancheBitmapAtRuntime(hashName, alghorithm); break; case "SHA3-512": alghorithm = new SHA3(512); CreateAvalancheBitmapAtRuntime(hashName, alghorithm); break; } }
public void HashAlghorithmSelectedFile(string hashName) { HashAlgorithm alghorithm; switch (hashName) { case "SHA1": alghorithm = new HashFunctions.SHA1(); HashSelectedFile(hashName, alghorithm); break; case "SHA224": alghorithm = new SHA2Managed(224); HashSelectedFile(hashName, alghorithm); break; case "SHA256": alghorithm = new SHA2Managed(256); HashSelectedFile(hashName, alghorithm); break; case "SHA384": alghorithm = new SHA2Managed(384); HashSelectedFile(hashName, alghorithm); break; case "SHA512": alghorithm = new SHA2Managed(512); HashSelectedFile(hashName, alghorithm); break; case "SHA3-224": alghorithm = new SHA3(224); HashSelectedFile(hashName, alghorithm); break; case "SHA3-256": alghorithm = new SHA3(256); HashSelectedFile(hashName, alghorithm); break; case "SHA3-384": alghorithm = new SHA3(384); HashSelectedFile(hashName, alghorithm); break; case "SHA3-512": alghorithm = new SHA3(512); HashSelectedFile(hashName, alghorithm); break; } }
static void Main() { var stopwatch = new Stopwatch(); byte[] data = { 0, 0, 5, 1, 1, 2 }; string word = "abc"; HashAlgorithm hash = new HashFunctions.SHA1(); stopwatch.Start(); Console.WriteLine($@"Proper HASH SHA1(data): {ByteArrayToString(hash.ComputeHash(data))}"); stopwatch.Stop(); Console.WriteLine($"Data hashed in: {stopwatch.Elapsed} s"); stopwatch.Reset(); stopwatch.Start(); Console.WriteLine($"Proper HASH SHA1 (word): {ByteArrayToString(hash.ComputeHash(Encoding.ASCII.GetBytes(word)))}"); stopwatch.Stop(); Console.WriteLine($"Data hashed in: {stopwatch.Elapsed} s"); Console.WriteLine($"Data hashed in: {stopwatch.ElapsedTicks} ticks"); Console.WriteLine($"Speed of hashing: {Encoding.ASCII.GetBytes(word).Length * 1000000 / stopwatch.Elapsed.Ticks} bps"); SHA3 hash5 = new SHA3(256); stopwatch.Reset(); stopwatch.Start(); Console.WriteLine($"Proper HASH SHA3-512 (word): {ByteArrayToString(hash5.ComputeHash(Encoding.UTF8.GetBytes(word)))}"); stopwatch.Stop(); Console.WriteLine($"Data hashed in: {stopwatch.Elapsed} s"); Console.WriteLine($"Data hashed in: {stopwatch.ElapsedTicks} ticks"); Console.WriteLine($"Speed of hashing: {((double)(Encoding.ASCII.GetBytes(word).Length / 1024) * 1000L * 1000L * 10L / (stopwatch.ElapsedTicks)):f2} bps"); SHA2Managed hash6 = new SHA2Managed(512); stopwatch.Reset(); Console.WriteLine($"Proper HASH SHA-512(word): {ByteArrayToString(hash6.ComputeHash(Encoding.UTF8.GetBytes(word)))}"); SHA2Managed hash7 = new SHA2Managed(224); stopwatch.Reset(); Console.WriteLine($"Proper HASH SHA-224(word): {ByteArrayToString(hash7.ComputeHash(Encoding.UTF8.GetBytes(word)))}"); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new HashFunctionAnalizerForm()); }
internal void SpeedTestOfHashFunctions(string hashName) { HashAlgorithm alghorithm; //generating randomize data var someData = new byte[1048576]; for (var i = 0; i < someData.Length; i++) { someData[i] = Convert.ToByte(RandomizeValue()); } var dataSize = Convert.ToInt32(dataSizeBar.Invoke(new Func <int>(DataSizeBarValue))); //generating missing collumns if (dataGridViewSpeedTest.ColumnCount <= 2 || dataGridViewSpeedTest.ColumnCount < (dataSize / 5)) { dataGridViewSpeedTest.Invoke(new Action <int>(AddCollumn), new object[] { dataSize }); } switch (hashName) { case "SHA1": alghorithm = new HashFunctions.SHA1(); SpeedCounting(alghorithm, hashName, someData, dataSize); break; case "SHA224": alghorithm = new SHA2Managed(224); SpeedCounting(alghorithm, hashName, someData, dataSize); break; case "SHA256": alghorithm = new SHA2Managed(256); SpeedCounting(alghorithm, hashName, someData, dataSize); break; case "SHA384": alghorithm = new SHA2Managed(384); SpeedCounting(alghorithm, hashName, someData, dataSize); break; case "SHA512": alghorithm = new SHA2Managed(512); SpeedCounting(alghorithm, hashName, someData, dataSize); break; case "SHA3-224": alghorithm = new SHA3(224); SpeedCounting(alghorithm, hashName, someData, dataSize); break; case "SHA3-256": alghorithm = new SHA3(256); SpeedCounting(alghorithm, hashName, someData, dataSize); break; case "SHA3-384": alghorithm = new SHA3(384); SpeedCounting(alghorithm, hashName, someData, dataSize); break; case "SHA3-512": alghorithm = new SHA3(512); SpeedCounting(alghorithm, hashName, someData, dataSize); break; } }