diff --git a/SabreTools.Hashing/HashTool.cs b/SabreTools.Hashing/HashTool.cs index db261f6..05c98b7 100644 --- a/SabreTools.Hashing/HashTool.cs +++ b/SabreTools.Hashing/HashTool.cs @@ -16,6 +16,10 @@ namespace SabreTools.Hashing /// Get CRC-32, MD5, and SHA-1 hashes from an input file path /// /// Path to the input file + /// Calculated file size on success, -1 on error + /// CRC-32 for the input file + /// MD5 for the input file + /// SHA-1 for the input file /// True if hashing was successful, false otherwise public static bool GetStandardHashes(string filename, out long size, out string? crc32, out string? md5, out string? sha1) { @@ -39,6 +43,10 @@ namespace SabreTools.Hashing /// Get CRC-32, MD5, and SHA-1 hashes from an input stream /// /// Input stream + /// Calculated file size on success, -1 on error + /// CRC-32 for the input file + /// MD5 for the input file + /// SHA-1 for the input file /// True if hashing was successful, false otherwise public static bool GetStandardHashes(Stream stream, out long size, out string? crc32, out string? md5, out string? sha1) { @@ -120,6 +128,7 @@ namespace SabreTools.Hashing /// Get hashes and size from an input file path /// /// Path to the input file + /// Amount of bytes read during hashing /// Dictionary containing hashes on success, null on error public static Dictionary? GetFileHashesAndSize(string filename, out long size) { @@ -134,6 +143,7 @@ namespace SabreTools.Hashing /// Get hashes and size from an input file path /// /// Path to the input file + /// Amount of bytes read during hashing /// Dictionary containing hashes on success, null on error public static Dictionary? GetFileHashArraysAndSize(string filename, out long size) { @@ -149,6 +159,7 @@ namespace SabreTools.Hashing /// /// Path to the input file /// Hash type to get from the file + /// Amount of bytes read during hashing /// Hash and size on success, null on error public static string? GetFileHashAndSize(string filename, HashType hashType, out long size) { @@ -161,6 +172,7 @@ namespace SabreTools.Hashing /// /// Path to the input file /// Hash type to get from the file + /// Amount of bytes read during hashing /// Hash and size on success, null on error public static byte[]? GetFileHashArrayAndSize(string filename, HashType hashType, out long size) { @@ -173,6 +185,7 @@ namespace SabreTools.Hashing /// /// Path to the input file /// Array of hash types to get from the file + /// Amount of bytes read during hashing /// Dictionary containing hashes on success, null on error public static Dictionary? GetFileHashesAndSize(string filename, HashType[] hashTypes, out long size) { @@ -195,6 +208,7 @@ namespace SabreTools.Hashing /// /// Path to the input file /// Array of hash types to get from the file + /// Amount of bytes read during hashing /// Dictionary containing hashes on success, null on error public static Dictionary? GetFileHashArraysAndSize(string filename, HashType[] hashTypes, out long size) { @@ -294,6 +308,7 @@ namespace SabreTools.Hashing /// Get hashes from an input Stream /// /// Stream to hash + /// Indicates if the source stream should be left open after hashing /// Dictionary containing hashes on success, null on error public static Dictionary? GetStreamHashes(Stream input, bool leaveOpen = false) => GetStreamHashesAndSize(input, leaveOpen, out _); @@ -302,6 +317,7 @@ namespace SabreTools.Hashing /// Get hashes from an input Stream /// /// Stream to hash + /// Indicates if the source stream should be left open after hashing /// Dictionary containing hashes on success, null on error public static Dictionary? GetStreamHashArrays(Stream input, bool leaveOpen = false) => GetStreamHashArraysAndSize(input, leaveOpen, out _); @@ -311,6 +327,7 @@ namespace SabreTools.Hashing /// /// Stream to hash /// Hash type to get from the file + /// Indicates if the source stream should be left open after hashing /// Hash on success, null on error public static string? GetStreamHash(Stream input, HashType hashType, bool leaveOpen = false) => GetStreamHashAndSize(input, hashType, leaveOpen, out _); @@ -320,6 +337,7 @@ namespace SabreTools.Hashing /// /// Stream to hash /// Hash type to get from the file + /// Indicates if the source stream should be left open after hashing /// Hash on success, null on error public static byte[]? GetStreamHashArray(Stream input, HashType hashType, bool leaveOpen = false) => GetStreamHashArrayAndSize(input, hashType, leaveOpen, out _); @@ -329,6 +347,7 @@ namespace SabreTools.Hashing /// /// Stream to hash /// Array of hash types to get from the file + /// Indicates if the source stream should be left open after hashing /// Dictionary containing hashes on success, null on error public static Dictionary? GetStreamHashes(Stream input, HashType[] hashTypes, bool leaveOpen = false) => GetStreamHashesAndSize(input, hashTypes, leaveOpen, out _); @@ -338,6 +357,7 @@ namespace SabreTools.Hashing /// /// Stream to hash /// Array of hash types to get from the file + /// Indicates if the source stream should be left open after hashing /// Dictionary containing hashes on success, null on error public static Dictionary? GetStreamHashArrays(Stream input, HashType[] hashTypes, bool leaveOpen = false) => GetStreamHashArraysAndSize(input, hashTypes, leaveOpen, out _); @@ -350,6 +370,7 @@ namespace SabreTools.Hashing /// Get hashes and size from an input Stream /// /// Stream to hash + /// Amount of bytes read during hashing /// Dictionary containing hashes on success, null on error public static Dictionary? GetStreamHashesAndSize(Stream input, out long size) => GetStreamHashesAndSize(input, leaveOpen: false, out size); @@ -358,6 +379,8 @@ namespace SabreTools.Hashing /// Get hashes and size from an input Stream /// /// Stream to hash + /// Indicates if the source stream should be left open after hashing + /// Amount of bytes read during hashing /// Dictionary containing hashes on success, null on error public static Dictionary? GetStreamHashesAndSize(Stream input, bool leaveOpen, out long size) { @@ -372,6 +395,7 @@ namespace SabreTools.Hashing /// Get hashes and size from an input Stream /// /// Stream to hash + /// Amount of bytes read during hashing /// Dictionary containing hashes on success, null on error public static Dictionary? GetStreamHashArraysAndSize(Stream input, out long size) => GetStreamHashArraysAndSize(input, leaveOpen: false, out size); @@ -380,6 +404,8 @@ namespace SabreTools.Hashing /// Get hashes and size from an input Stream /// /// Stream to hash + /// Indicates if the source stream should be left open after hashing + /// Amount of bytes read during hashing /// Dictionary containing hashes on success, null on error public static Dictionary? GetStreamHashArraysAndSize(Stream input, bool leaveOpen, out long size) { @@ -395,6 +421,7 @@ namespace SabreTools.Hashing /// /// Stream to hash /// Hash type to get from the file + /// Amount of bytes read during hashing /// Hash on success, null on error public static string? GetStreamHashAndSize(Stream input, HashType hashType, out long size) => GetStreamHashAndSize(input, hashType, leaveOpen: false, out size); @@ -404,6 +431,8 @@ namespace SabreTools.Hashing /// /// Stream to hash /// Hash type to get from the file + /// Indicates if the source stream should be left open after hashing + /// Amount of bytes read during hashing /// Hash on success, null on error public static string? GetStreamHashAndSize(Stream input, HashType hashType, bool leaveOpen, out long size) { @@ -416,6 +445,7 @@ namespace SabreTools.Hashing /// /// Stream to hash /// Hash type to get from the file + /// Amount of bytes read during hashing /// Hash on success, null on error public static byte[]? GetStreamHashArrayAndSize(Stream input, HashType hashType, out long size) => GetStreamHashArrayAndSize(input, hashType, leaveOpen: false, out size); @@ -425,6 +455,8 @@ namespace SabreTools.Hashing /// /// Stream to hash /// Hash type to get from the file + /// Indicates if the source stream should be left open after hashing + /// Amount of bytes read during hashing /// Hash on success, null on error public static byte[]? GetStreamHashArrayAndSize(Stream input, HashType hashType, bool leaveOpen, out long size) { @@ -437,6 +469,7 @@ namespace SabreTools.Hashing /// /// Stream to hash /// Array of hash types to get from the file + /// Amount of bytes read during hashing /// Dictionary containing hashes on success, null on error public static Dictionary? GetStreamHashesAndSize(Stream input, HashType[] hashTypes, out long size) => GetStreamHashesAndSize(input, hashTypes, leaveOpen: false, out size); @@ -446,6 +479,8 @@ namespace SabreTools.Hashing /// /// Stream to hash /// Array of hash types to get from the file + /// Indicates if the source stream should be left open after hashing + /// Amount of bytes read during hashing /// Dictionary containing hashes on success, null on error public static Dictionary? GetStreamHashesAndSize(Stream input, HashType[] hashTypes, bool leaveOpen, out long size) { @@ -493,6 +528,7 @@ namespace SabreTools.Hashing /// /// Stream to hash /// Array of hash types to get from the file + /// Amount of bytes read during hashing /// Dictionary containing hashes on success, null on error public static Dictionary? GetStreamHashArraysAndSize(Stream input, HashType[] hashTypes, out long size) => GetStreamHashArraysAndSize(input, hashTypes, leaveOpen: false, out size); @@ -502,6 +538,8 @@ namespace SabreTools.Hashing /// /// Stream to hash /// Array of hash types to get from the file + /// Indicates if the source stream should be left open after hashing + /// Amount of bytes read during hashing /// Dictionary containing hashes on success, null on error public static Dictionary? GetStreamHashArraysAndSize(Stream input, HashType[] hashTypes, bool leaveOpen, out long size) { @@ -545,11 +583,12 @@ namespace SabreTools.Hashing } /// - /// Get hashes from an input stream + /// Get hashes and size from an input Stream /// - /// - /// - /// + /// Stream to hash + /// Array of hash types to get from the file + /// Indicates if the source stream should be left open after hashing + /// Amount of bytes read during hashing /// private static Dictionary? GetStreamHashesInternal(Stream input, HashType[] hashTypes, bool leaveOpen, out long size) {