mirror of
https://github.com/SabreTools/SabreTools.Hashing.git
synced 2026-07-08 18:06:40 +00:00
Shortcut on 0-byte inputs
This commit is contained in:
@@ -342,6 +342,17 @@ namespace SabreTools.Hashing
|
||||
// Create the output dictionary
|
||||
var hashDict = new Dictionary<HashType, string?>();
|
||||
|
||||
// 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<HashType, byte[]?>();
|
||||
|
||||
// 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)
|
||||
|
||||
Reference in New Issue
Block a user