Skip to content

Commit

Permalink
SVN Clean-up and Bouncy Castle Conversion
Browse files Browse the repository at this point in the history
This commit cleans up a few bits of cruft from our conversion from
Subversion to git, like removing the batch files and template files that
added SVN revision numbers to the application version numbers. git
doesn't have a concept like revision numbers; well, it does, but not
something that would be easy to add to a version number like the SVN
revisions. While I liked that convention, I'm afraid there's no easy
analog I can use from here on out.

I also started the transition from using Microsoft's Crypto API for the
hashing routines to the Legion of the Bouncy Castle. By moving to the
Bouncy Castle code, we can (a) add more hashing functions immediately
and (b) be better prepared to add new hashes (like SHA3) once the Bouncy
Castle folks release future updates. For now, the new hashes added are
SHA-224, RIPEMD-128, RIPEMD-256, RIPEMD-320, AND GOST3411. (While Bouncy
Castle supports MD2 and MD4, I elected not to support them in WinHasher;
I see MD5 being removed eventually as well.) This also means that the
internal implementations of Tiger and Whirlpool are no longer needed and
have been removed; both are already supported by the Bouncy Castle
library.

Also did a little bit of rearranging to consolidate a few things, like
converting hashes and output types to their display strings (and back)
within the WinHasherCore.HashEngine class rather than in a dozen
different places. This should also make it easier to add new hashes
later.

I also added changes to support using the main WinHasher app in
"portable" mode, meaning it will not make reads or writes to the
Registry while in GUI mode. To launch WinHasher in portable mode, add
the "-portable" command-line parameter on launch. Note that while the
SendTo shortcuts technically run in GUI mode, they don't launch the full
GUI and do not read or write to the Registry. None of the command-line
apps touch the Registry either, so the portable flag only affects the
main GUI app.

None of this really applies to any of the open issues, so there's still
a good bit left to tweak. The only issue touched here is #8; I removed
the private showMD5warning flag and all of its references, so the MD5
warning should never be displayed now. I'm not sure I'd consider this a
"fix", but I'll concede that it's an annoyance. We'll leave the warnings
to the documentation from here on out.
  • Loading branch information
gpfjeff committed Jun 30, 2015
1 parent da4083d commit ee7928a
Show file tree
Hide file tree
Showing 32 changed files with 1,058 additions and 2,478 deletions.
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
hash/bin
hash/obj
md5/bin
md5/obj
sha1/bin
sha1/obj
WinHasher/bin
WinHasher/obj
WinHasherCore/bin
WinHasherCore/obj
WinHasher.v11.suo
Binary file added BouncyCastle.Crypto.dll
Binary file not shown.
296 changes: 148 additions & 148 deletions InnoSetup/WinHasher.iss.template → InnoSetup/WinHasher.iss

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

Jeffrey T. Darlington
June 28, 2011
http://code.google.com/p/winhasher/
https://github.com/gpfjeff/winhasher

WinHasher is a free, Open Source cryptographic hash or digest generator written in C# using Microsoft's .NET 2.0 Framework. It can be used to verify file download integrity, compare two or more files for modifications, and to some degree generate strong, unique passwords.

Expand Down
35 changes: 0 additions & 35 deletions SubWCRev_batch.bat

This file was deleted.

2 changes: 1 addition & 1 deletion WinHasher/AboutDialog.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions WinHasher/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
</configuration>
425 changes: 254 additions & 171 deletions WinHasher/MainForm.cs

Large diffs are not rendered by default.

46 changes: 31 additions & 15 deletions WinHasher/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,12 @@
* ResultDialog class rather than MessageBox to give the user easier access to the hash value
* and to allow them to compare the hash with a pre-computed value more easily.
*
* This program is Copyright 2009, Jeffrey T. Darlington.
* UPDATED June 29, 2015 (1.7): Updates for Bouncy Castle conversion as well as to enable
* "portable" mode
*
* This program is Copyright 2015, Jeffrey T. Darlington.
* E-mail: [email protected]
* Web: http://www.gpf-comics.com/
* Web: https://github.com/gpfjeff/winhasher
*
* This program is free software; you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation; either version 2
Expand Down Expand Up @@ -77,6 +80,11 @@ static void Main(string[] args)
// If no command-line arguments are given, go ahead and run the program in
// interactive GUI mode:
if (args.Length == 0) { Application.Run(new MainForm()); }
// If we have one and only one command-line argument and it's the portable
// flag, load the main application in portable mode (i.e. no writes to the
// registry):
else if (args.Length == 1 && args[0].ToLower() == "-portable")
{ Application.Run(new MainForm(true)); }
// Otherwise, assume we're going to process one or more files, show the results
// in a dialog box, then exit:
else
Expand All @@ -85,11 +93,10 @@ static void Main(string[] args)
// arguments. We can't work with the argument array itself because we may
// need to strip off the first one if it's a hash switch.
string[] files = null;
// Default to doing SHA-1 unless otherwise instructed:
Hashes hash = Hashes.SHA1;
string hashString = "SHA-1";
// By default, output hex:
OutputType outputType = OutputType.Hex;
// Set our default hash and output type:
Hashes hash = HashEngine.DefaultHash;
string hashString = HashEngine.GetHashName(hash);
OutputType outputType = HashEngine.DefaultOutputType;
// All our command switches come first, so step through them:
while (args[0].StartsWith("-"))
{
Expand All @@ -99,31 +106,39 @@ static void Main(string[] args)
// Most of these determine which hash to use:
case "-md5":
hash = Hashes.MD5;
hashString = "MD5";
break;
case "-sha1":
hash = Hashes.SHA1;
hashString = "SHA-1";
break;
case "-sha224":
hash = Hashes.SHA224;
break;
case "-sha256":
hash = Hashes.SHA256;
hashString = "SHA-256";
break;
case "-sha384":
hash = Hashes.SHA384;
break;
case "-sha512":
hash = Hashes.SHA512;
hashString = "SHA-512";
break;
case "-ripemd106":
case "-ripemd128":
hash = Hashes.RIPEMD128;
break;
case "-ripemd160":
hash = Hashes.RIPEMD160;
hashString = "RIPEMD-160";
break;
case "-ripemd256":
hash = Hashes.RIPEMD256;
break;
case "-ripemd320":
hash = Hashes.RIPEMD320;
break;
case "-whirlpool":
hash = Hashes.Whirlpool;
hashString = "Whirlpool";
break;
case "-tiger":
hash = Hashes.Tiger;
hashString = "Tiger";
break;
// But this switch enables Base64 hashing:
case "-base64":
Expand All @@ -143,6 +158,7 @@ static void Main(string[] args)
MessageBoxButtons.OK, MessageBoxIcon.Error);
break;
}
hashString = HashEngine.GetHashName(hash);
// Now shift the array down to the next argument. I wish there was a better,
// more efficient way of doing this (like a Perl or PHP shift()), but this is
// all I know of using simple arrays:
Expand Down
33 changes: 10 additions & 23 deletions WinHasher/ProgressDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@
* UPDATED February 12, 2009 (1.4): Added necessary flags and members to introduce abstracted
* output type methods in HashEngine.
*
* This program is Copyright 2009, Jeffrey T. Darlington.
* UPDATED June 29, 2015 (1.7): Changes to default hash and output type values
*
* This program is Copyright 2015, Jeffrey T. Darlington.
* E-mail: [email protected]
* Web: http://www.gpf-comics.com/
* Web: https://github.com/gpfjeff/winhasher
*
* This program is free software; you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation; either version 2
Expand Down Expand Up @@ -82,7 +84,7 @@ public enum ResultStatus
/// <summary>
/// The hash algorithm being used
/// </summary>
private Hashes hashAlgorithm;
private Hashes hashAlgorithm = HashEngine.DefaultHash;

/// <summary>
/// A System.ComponentModel.BackgroundWorker object which will perform the hashing
Expand Down Expand Up @@ -113,7 +115,7 @@ public enum ResultStatus
/// <summary>
/// The output encoding for the resulting hash
/// </summary>
private OutputType outputType = OutputType.Hex;
private OutputType outputType = HashEngine.DefaultOutputType;

#endregion

Expand Down Expand Up @@ -170,21 +172,6 @@ public OutputType OutputType
set { outputType = value; }
}

/// <summary>
/// DEPRECIATED: Use OutputType instead. A boolean flag indicating whether the output
/// should be in Base64 format (true) or hexadecimal (false). The default is false, or
/// output in hexadecimal.
/// </summary>
public bool Base64
{
get { return outputType == OutputType.Base64; }
set
{
if (value) outputType = OutputType.Base64;
else outputType = OutputType.Hex;
}
}

#endregion

/// <summary>
Expand Down Expand Up @@ -246,7 +233,7 @@ public ProgressDialog(string[] fileList, Hashes hashAlgorithm, bool centerInScre
/// <param name="centerInScreen">True to center in the middle of the screen, false to
/// center around the parent window</param>
public ProgressDialog(string[] fileList, Hashes hashAlgorithm, bool centerInScreen)
: this(fileList, hashAlgorithm, centerInScreen, OutputType.Hex)
: this(fileList, hashAlgorithm, centerInScreen, HashEngine.DefaultOutputType)
{ }


Expand All @@ -258,7 +245,7 @@ public ProgressDialog(string[] fileList, Hashes hashAlgorithm, bool centerInScre
/// <param name="hashAlgorithm">The hashing algorithm to use in the comparison</param>
public ProgressDialog(string[] fileList, Hashes hashAlgorithm)
:
this(fileList, hashAlgorithm, false, OutputType.Hex)
this(fileList, hashAlgorithm, false, HashEngine.DefaultOutputType)
{
}

Expand Down Expand Up @@ -323,7 +310,7 @@ public ProgressDialog(string filename, Hashes hashAlgorithm, bool centerInScreen
/// <param name="centerInScreen">True to center in the middle of the screen, false to
/// center around the parent window</param>
public ProgressDialog(string filename, Hashes hashAlgorithm, bool centerInScreen)
: this(filename, hashAlgorithm, centerInScreen, OutputType.Hex)
: this(filename, hashAlgorithm, centerInScreen, HashEngine.DefaultOutputType)
{
}

Expand All @@ -335,7 +322,7 @@ public ProgressDialog(string filename, Hashes hashAlgorithm, bool centerInScreen
/// <param name="hashAlgorithm">The hashing algorithm to use</param>
public ProgressDialog(string filename, Hashes hashAlgorithm)
:
this(filename, hashAlgorithm, false, OutputType.Hex)
this(filename, hashAlgorithm, false, HashEngine.DefaultOutputType)
{
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
/* JTD: The following text has been added has been added to force TortoiseSVN's
SubWCRev command to update the AssemblyInfo.cs templates with the appropriate
revision number. Undoubtedly, this only works when the tempalte itself is
modified, although we want it to occur when any code changes. So just before
doing a release build, make sure to change the random string below to some-
thing new to force SubWCRev to add the new info.
Revision Tag: Lz7peoVyVuL97tG5UTl7xBeWfLYtllY9urc3cZUvsAFq5WVAYuFxaIJcpUK */
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("WinHasher")]
[assembly: AssemblyDescription("This .NET application computes the cryptographic hash of one or more files. Single file hashes can be used to verify downloads or ensure a file has not been tampered with. The hashes of multiple files can be compared to see if the contents of those files are identical.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("GPF Comics")]
[assembly: AssemblyProduct("WinHasher")]
[assembly: AssemblyCopyright("© Copyright $WCDATE=%Y$, Jeffrey T. Darlington")]
[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("42a8095e-6f96-4cf5-9f32-342add02e93d")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
[assembly: AssemblyVersion("1.7.0.$WCREV$")]
[assembly: AssemblyFileVersion("1.7.0.$WCREV$")]
/* JTD: The following text has been added has been added to force TortoiseSVN's
SubWCRev command to update the AssemblyInfo.cs templates with the appropriate
revision number. Undoubtedly, this only works when the tempalte itself is
modified, although we want it to occur when any code changes. So just before
doing a release build, make sure to change the random string below to some-
thing new to force SubWCRev to add the new info.
Revision Tag: Lz7peoVyVuL97tG5UTl7xBeWfLYtllY9urc3cZUvsAFq5WVAYuFxaIJcpUK */
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("WinHasher")]
[assembly: AssemblyDescription("This .NET application computes the cryptographic hash of one or more files. Single file hashes can be used to verify downloads or ensure a file has not been tampered with. The hashes of multiple files can be compared to see if the contents of those files are identical.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("GPF Comics")]
[assembly: AssemblyProduct("WinHasher")]
[assembly: AssemblyCopyright("© Copyright 2015, Jeffrey T. Darlington")]
[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("42a8095e-6f96-4cf5-9f32-342add02e93d")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
[assembly: AssemblyVersion("1.7.0.0")]
[assembly: AssemblyFileVersion("1.7.0.0")]
4 changes: 2 additions & 2 deletions WinHasher/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion WinHasher/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,6 @@ library. If this is what you want to do, use the GNU Library General
Public License instead of this License.</value>
</data>
<data name="URL" xml:space="preserve">
<value>http://www.gpf-comics.com/dl/winhasher/</value>
<value>https://github.com/gpfjeff/winhasher</value>
</data>
</root>
Loading

0 comments on commit ee7928a

Please sign in to comment.