commit 299b3073f51cdfc88693b43e1b1f2dd3901c878d Author: Brandon Scott Date: Mon Jul 3 01:43:27 2017 -0500 Initial commit. diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..940794e --- /dev/null +++ b/.gitignore @@ -0,0 +1,288 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ +**/Properties/launchSettings.json + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# TODO: Comment the next line if you want to checkin your web deploy settings +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Typescript v1 declaration files +typings/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs diff --git a/FileHashCalculator.sln b/FileHashCalculator.sln new file mode 100644 index 0000000..fe7baf7 --- /dev/null +++ b/FileHashCalculator.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FileHashCalculator", "FileHashCalculator\FileHashCalculator.csproj", "{F20C029B-AEE7-4676-BF46-B6E59FB9C78E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x86 = Debug|x86 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F20C029B-AEE7-4676-BF46-B6E59FB9C78E}.Debug|x86.ActiveCfg = Debug|x86 + {F20C029B-AEE7-4676-BF46-B6E59FB9C78E}.Debug|x86.Build.0 = Debug|x86 + {F20C029B-AEE7-4676-BF46-B6E59FB9C78E}.Release|x86.ActiveCfg = Release|x86 + {F20C029B-AEE7-4676-BF46-B6E59FB9C78E}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/FileHashCalculator/CustomHashAlgorithms/MD2.cs b/FileHashCalculator/CustomHashAlgorithms/MD2.cs new file mode 100644 index 0000000..b47d7a6 --- /dev/null +++ b/FileHashCalculator/CustomHashAlgorithms/MD2.cs @@ -0,0 +1,113 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Security.Cryptography; + +namespace FileHashCalculator.CustomHashAlgorithms +{ + public class MD2 + { + byte[] data = new byte[16]; + byte[] state = new byte[48]; + byte[] checksum = new byte[16]; + int len; + + private byte[] s = new byte[] { 41, 46, 67, 201, 162, 216, 124, 1, 61, 54, 84, 161, 236, 240, 6, + 19, 98, 167, 5, 243, 192, 199, 115, 140, 152, 147, 43, 217, 188, + 76, 130, 202, 30, 155, 87, 60, 253, 212, 224, 22, 103, 66, 111, 24, + 138, 23, 229, 18, 190, 78, 196, 214, 218, 158, 222, 73, 160, 251, + 245, 142, 187, 47, 238, 122, 169, 104, 121, 145, 21, 178, 7, 63, + 148, 194, 16, 137, 11, 34, 95, 33, 128, 127, 93, 154, 90, 144, 50, + 39, 53, 62, 204, 231, 191, 247, 151, 3, 255, 25, 48, 179, 72, 165, + 181, 209, 215, 94, 146, 42, 172, 86, 170, 198, 79, 184, 56, 210, + 150, 164, 125, 182, 118, 252, 107, 226, 156, 116, 4, 241, 69, 157, + 112, 89, 100, 113, 135, 32, 134, 91, 207, 101, 230, 45, 168, 2, 27, + 96, 37, 173, 174, 176, 185, 246, 28, 70, 97, 105, 52, 64, 126, 15, + 85, 71, 163, 35, 221, 81, 175, 58, 195, 92, 249, 206, 186, 197, + 234, 38, 44, 83, 13, 110, 133, 40, 132, 9, 211, 223, 205, 244, 65, + 129, 77, 82, 106, 220, 55, 200, 108, 193, 171, 250, 36, 225, 123, + 8, 12, 189, 177, 74, 120, 136, 149, 139, 227, 99, 232, 109, 233, + 203, 213, 254, 59, 0, 29, 57, 242, 239, 183, 14, 102, 88, 208, 228, + 166, 119, 114, 248, 235, 117, 75, 10, 49, 68, 80, 180, 143, 237, + 31, 26, 219, 153, 141, 51, 159, 17, 131, 20 + }; + + public void Initialize() + { + int i; + + for (i = 0; i < 48; ++i) + this.state[i] = 0; + + for (i = 0; i < 16; ++i) + this.checksum[i] = 0; + + this.len = 0; + } + + public void Transform(byte[] data) + { + int j, k, t; + + for (j = 0; j < 16; ++j) + { + this.state[j + 16] = data[j]; + this.state[j + 32] = (byte)(this.state[j + 16] ^ this.state[j]); + } + + t = 0; + for (j = 0; j < 18; ++j) + { + for (k = 0; k < 48; ++k) + { + this.state[k] ^= s[t]; + t = this.state[k]; + } + t = (t + j) & 0xFF; + } + + t = this.checksum[15]; + for (j = 0; j < 16; ++j) + { + this.checksum[j] ^= s[data[j] ^ t]; + t = this.checksum[j]; + } + } + + public void Update(byte[] data, int len) + { + int t,i; + for (i=0; i < len; ++i) { + this.data[this.len] = data[i]; + this.len++; + if (this.len == 16) { + Transform(this.data); + this.len = 0; + } + } + } + + public byte[] Final() + { + int to_pad = 16 - this.len; + byte[] output = new byte[16]; + + while (this.len < 16) + this.data[this.len++] = (byte)to_pad; + + Transform(this.data); + Transform(this.checksum); + + Array.Copy(this.state, output, 16); + return output; + } + + public byte[] Compute(byte[] data) + { + Initialize(); + Update(data, data.Length); + return Final(); + } + } +} diff --git a/FileHashCalculator/FileHashCalculator.csproj b/FileHashCalculator/FileHashCalculator.csproj new file mode 100644 index 0000000..ce64990 --- /dev/null +++ b/FileHashCalculator/FileHashCalculator.csproj @@ -0,0 +1,89 @@ + + + + Debug + x86 + 8.0.30703 + 2.0 + {F20C029B-AEE7-4676-BF46-B6E59FB9C78E} + WinExe + Properties + FileHashCalculator + FileHashCalculator + v4.0 + Client + 512 + + + x86 + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + x86 + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + Form + + + MainForm.cs + + + + + + MainForm.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + \ No newline at end of file diff --git a/FileHashCalculator/MainForm.Designer.cs b/FileHashCalculator/MainForm.Designer.cs new file mode 100644 index 0000000..b2bdc38 --- /dev/null +++ b/FileHashCalculator/MainForm.Designer.cs @@ -0,0 +1,142 @@ +namespace FileHashCalculator +{ + partial class MainForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.generateHashesButton = new System.Windows.Forms.Button(); + this.fileTextBox = new System.Windows.Forms.TextBox(); + this.browseButton = new System.Windows.Forms.Button(); + this.hashProgressBar = new System.Windows.Forms.ProgressBar(); + this.hashListView = new System.Windows.Forms.ListView(); + this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.hashPercentageLabel = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // generateHashesButton + // + this.generateHashesButton.Location = new System.Drawing.Point(352, 40); + this.generateHashesButton.Name = "generateHashesButton"; + this.generateHashesButton.Size = new System.Drawing.Size(88, 24); + this.generateHashesButton.TabIndex = 0; + this.generateHashesButton.Text = "Generate"; + this.generateHashesButton.UseVisualStyleBackColor = true; + this.generateHashesButton.Click += new System.EventHandler(this.generateHashesButton_Click); + // + // fileTextBox + // + this.fileTextBox.Location = new System.Drawing.Point(8, 8); + this.fileTextBox.Name = "fileTextBox"; + this.fileTextBox.ReadOnly = true; + this.fileTextBox.Size = new System.Drawing.Size(336, 20); + this.fileTextBox.TabIndex = 1; + // + // browseButton + // + this.browseButton.Location = new System.Drawing.Point(352, 8); + this.browseButton.Name = "browseButton"; + this.browseButton.Size = new System.Drawing.Size(88, 24); + this.browseButton.TabIndex = 2; + this.browseButton.Text = "Browse"; + this.browseButton.UseVisualStyleBackColor = true; + this.browseButton.Click += new System.EventHandler(this.browseButton_Click); + // + // hashProgressBar + // + this.hashProgressBar.Location = new System.Drawing.Point(8, 32); + this.hashProgressBar.Name = "hashProgressBar"; + this.hashProgressBar.Size = new System.Drawing.Size(288, 16); + this.hashProgressBar.TabIndex = 3; + // + // hashListView + // + this.hashListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeader1, + this.columnHeader2}); + this.hashListView.FullRowSelect = true; + this.hashListView.GridLines = true; + this.hashListView.Location = new System.Drawing.Point(8, 72); + this.hashListView.Name = "hashListView"; + this.hashListView.Size = new System.Drawing.Size(432, 248); + this.hashListView.TabIndex = 4; + this.hashListView.UseCompatibleStateImageBehavior = false; + this.hashListView.View = System.Windows.Forms.View.Details; + // + // columnHeader1 + // + this.columnHeader1.Text = "Algorithm"; + this.columnHeader1.Width = 73; + // + // columnHeader2 + // + this.columnHeader2.Text = "Hash"; + this.columnHeader2.Width = 327; + // + // hashPercentageLabel + // + this.hashPercentageLabel.AutoSize = true; + this.hashPercentageLabel.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; + this.hashPercentageLabel.Location = new System.Drawing.Point(304, 34); + this.hashPercentageLabel.Name = "hashPercentageLabel"; + this.hashPercentageLabel.Size = new System.Drawing.Size(23, 15); + this.hashPercentageLabel.TabIndex = 5; + this.hashPercentageLabel.Text = "0%"; + // + // MainForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(449, 330); + this.Controls.Add(this.hashPercentageLabel); + this.Controls.Add(this.hashListView); + this.Controls.Add(this.hashProgressBar); + this.Controls.Add(this.browseButton); + this.Controls.Add(this.fileTextBox); + this.Controls.Add(this.generateHashesButton); + this.Name = "MainForm"; + this.Text = "File Hash Generator"; + this.Load += new System.EventHandler(this.MainForm_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button generateHashesButton; + private System.Windows.Forms.TextBox fileTextBox; + private System.Windows.Forms.Button browseButton; + private System.Windows.Forms.ProgressBar hashProgressBar; + private System.Windows.Forms.ListView hashListView; + private System.Windows.Forms.ColumnHeader columnHeader1; + private System.Windows.Forms.ColumnHeader columnHeader2; + private System.Windows.Forms.Label hashPercentageLabel; + + } +} + diff --git a/FileHashCalculator/MainForm.cs b/FileHashCalculator/MainForm.cs new file mode 100644 index 0000000..14a68dc --- /dev/null +++ b/FileHashCalculator/MainForm.cs @@ -0,0 +1,130 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using System.Security.Cryptography; +using System.IO; +using System.Threading; + +namespace FileHashCalculator +{ + public partial class MainForm : Form + { + private string[] _algoList = new string[] { "MD5", "SHA1", "SHA256", "SHA384", "SHA512" }; + private FileStream _file; + private Thread _hashThread; + private bool _started; + + const int BUFFER_SIZE = 4096; + + public MainForm() + { + InitializeComponent(); + } + + private void browseButton_Click(object sender, EventArgs e) + { + using (OpenFileDialog openFile = new OpenFileDialog()) + { + openFile.Filter = "All files (*.*)|*.*"; + + if (openFile.ShowDialog() == DialogResult.OK) + { + try + { + _file = (FileStream)openFile.OpenFile(); + fileTextBox.Text = openFile.FileName; + } + catch (ArgumentNullException ex) + { + Console.WriteLine(ex.Message); + } + } + } + } + + private void generateHashesButton_Click(object sender, EventArgs e) + { + hashListView.Items.Clear(); + + if (_file == null) + return; + + if (_hashThread == null || _hashThread.IsAlive == false) + _hashThread = new Thread(new ThreadStart(HashThreadProc)); + + if (_started) + return; + + _hashThread.Start(); + } + + private void MainForm_Load(object sender, EventArgs e) + { + + } + + private void HashThreadProc() + { + _started = true; + + foreach (string hashAlgoName in _algoList) + { + // create a new hash object for the algorithm + HashAlgorithm hashAlgoObject = HashAlgorithm.Create(hashAlgoName); + // updates form with progress updates and returns hash + byte[] hash = CalculateHashWithProgress(_file, hashAlgoObject); + // just to make this look a little cleaner + string hashString = BitConverter.ToString(hash).Replace("-", "").ToLower(); + // thread safe call to add it to the list. + AddHashToList(hashAlgoName, hashString); + } + + _started = false; + } + + private byte[] CalculateHashWithProgress(Stream input, HashAlgorithm algorithm) + { + byte[] buffer = new byte[BUFFER_SIZE]; + int readCount; + long streamSize = input.Length; + long totalBytesRead = 0; + + input.Position = 0; // reset position to beginning of the file. + + while ((readCount = input.Read(buffer, 0, BUFFER_SIZE)) > 0) + { + algorithm.TransformBlock(buffer, 0, readCount, buffer, 0); + totalBytesRead += readCount; + UpdateProgress((int)((double)totalBytesRead * 100 / streamSize)); + } + + algorithm.TransformFinalBlock(buffer, 0, readCount); + UpdateProgress((int)((double)totalBytesRead * 100 / streamSize)); + + return algorithm.Hash; + } + + private void UpdateProgress(int progress) + { + this.Invoke(new MethodInvoker(delegate + { + hashProgressBar.Value = progress; + hashPercentageLabel.Text = String.Format("{0}%", progress); + })); + } + + private void AddHashToList(string algo, string hash) + { + this.Invoke(new MethodInvoker(delegate { + ListViewItem lvi = new ListViewItem(algo); + lvi.SubItems.Add(hash); + hashListView.Items.Add(lvi); + })); + } + } +} diff --git a/FileHashCalculator/MainForm.resx b/FileHashCalculator/MainForm.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/FileHashCalculator/MainForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/FileHashCalculator/Program.cs b/FileHashCalculator/Program.cs new file mode 100644 index 0000000..52f7df0 --- /dev/null +++ b/FileHashCalculator/Program.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Windows.Forms; + +namespace FileHashCalculator +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new MainForm()); + } + } +} diff --git a/FileHashCalculator/Properties/AssemblyInfo.cs b/FileHashCalculator/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..03a1607 --- /dev/null +++ b/FileHashCalculator/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("FileHashCalculator")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Xeon Productions")] +[assembly: AssemblyProduct("FileHashCalculator")] +[assembly: AssemblyCopyright("Copyright © Xeon Productions 2012")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("c0999fe5-3a2f-4fa4-b935-d7d4be896245")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/FileHashCalculator/Properties/Resources.Designer.cs b/FileHashCalculator/Properties/Resources.Designer.cs new file mode 100644 index 0000000..6a133b9 --- /dev/null +++ b/FileHashCalculator/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.269 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace FileHashCalculator.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FileHashCalculator.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/FileHashCalculator/Properties/Resources.resx b/FileHashCalculator/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/FileHashCalculator/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/FileHashCalculator/Properties/Settings.Designer.cs b/FileHashCalculator/Properties/Settings.Designer.cs new file mode 100644 index 0000000..a7e8ecb --- /dev/null +++ b/FileHashCalculator/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.269 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace FileHashCalculator.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/FileHashCalculator/Properties/Settings.settings b/FileHashCalculator/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/FileHashCalculator/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/FileHashCalculator/Utilities.cs b/FileHashCalculator/Utilities.cs new file mode 100644 index 0000000..0fe4920 --- /dev/null +++ b/FileHashCalculator/Utilities.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Security.Cryptography; +using System.IO; + +namespace FileHashCalculator +{ + class Utilities + { + public static string Md5Hash(string fileName) + { + using (MD5 md5 = new MD5CryptoServiceProvider()) + { + using (FileStream file = new FileStream(fileName, FileMode.Open)) + { + byte[] retVal = md5.ComputeHash(file); + return BitConverter.ToString(retVal).Replace("-", ""); // hex string + } + } + } + } +} diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d378d57 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017 Brandon Scott + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..665283e --- /dev/null +++ b/README.md @@ -0,0 +1,17 @@ +# File Hash Calculator + +## Author + +Brandon Scott + +## About + +This is a file hash calculator I made to familiarize myself with TransformBlock and TransformFinalBlock, it uses C#, WinForms, and multi-threading. It supports MD5, SHA1, SHA256, SHA384, and SHA512. + +## Screenshot + +![Alt text](/Screenshot.png?raw=true "Screenshot") + +## License + +All code in this project is licensed under the MIT license. \ No newline at end of file diff --git a/Screenshot.png b/Screenshot.png new file mode 100644 index 0000000..3632f88 Binary files /dev/null and b/Screenshot.png differ