-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SVN Clean-up and Bouncy Castle Conversion
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
Showing
32 changed files
with
1,058 additions
and
2,478 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 not shown.
296 changes: 148 additions & 148 deletions
296
InnoSetup/WinHasher.iss.template → InnoSetup/WinHasher.iss
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
</configuration> |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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 | ||
|
@@ -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("-")) | ||
{ | ||
|
@@ -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": | ||
|
@@ -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: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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 | ||
|
@@ -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 | ||
|
||
|
@@ -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> | ||
|
@@ -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) | ||
{ } | ||
|
||
|
||
|
@@ -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) | ||
{ | ||
} | ||
|
||
|
@@ -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) | ||
{ | ||
} | ||
|
||
|
@@ -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) | ||
{ | ||
} | ||
|
||
|
82 changes: 41 additions & 41 deletions
82
...asher/Properties/AssemblyInfo.cs.template → WinHasher/Properties/AssemblyInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")] |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.