diff --git a/SabreTools.Hashing/HashTool.cs b/SabreTools.Hashing/HashTool.cs index 6737d84..b6d6439 100644 --- a/SabreTools.Hashing/HashTool.cs +++ b/SabreTools.Hashing/HashTool.cs @@ -342,6 +342,17 @@ namespace SabreTools.Hashing // Create the output dictionary var hashDict = new Dictionary(); + // Shortcut if we have a 0-byte input + if (input.Length == 0) + { + foreach (var hashType in hashTypes) + { + hashDict[hashType] = ZeroHash.GetString(hashType); + } + + return hashDict; + } + // Run the hashing var hashers = GetStreamHashesInternal(input, hashTypes, leaveOpen); if (hashers == null) @@ -373,6 +384,17 @@ namespace SabreTools.Hashing // Create the output dictionary var hashDict = new Dictionary(); + // Shortcut if we have a 0-byte input + if (input.Length == 0) + { + foreach (var hashType in hashTypes) + { + hashDict[hashType] = ZeroHash.GetBytes(hashType); + } + + return hashDict; + } + // Run the hashing var hashers = GetStreamHashesInternal(input, hashTypes, leaveOpen); if (hashers == null)