diff --git a/HashTool.cs b/HashTool.cs index d821923..7ae1242 100644 --- a/HashTool.cs +++ b/HashTool.cs @@ -123,6 +123,45 @@ namespace SabreTools.Hashing #endregion + #region Byte Array Hashes + + /// + /// Get hashes from an input byte array + /// + /// Byte array to hash + /// Dictionary containing hashes on success, null on error + public static Dictionary? GetByteArrayHashes(byte[] input) + { + // Create a hash array for all entries + HashType[] hashTypes = (HashType[])Enum.GetValues(typeof(HashType)); + + // Return the hashes from the stream + return GetStreamHashes(new MemoryStream(input), hashTypes); + } + + /// + /// Get a hash from an input byte array + /// + /// Byte array to hash + /// Hash type to get from the file + /// Dictionary containing hashes on success, null on error + public static string? GetByteArrayHash(byte[] input, HashType hashType) + { + var hashes = GetStreamHashes(new MemoryStream(input), [hashType]); + return hashes?[hashType]; + } + + /// + /// Get hashes from an input byte array + /// + /// Byte array to hash + /// Array of hash types to get from the file + /// Dictionary containing hashes on success, null on error + public static Dictionary? GetByteArrayHashes(byte[] input, HashType[] hashTypes) + => GetStreamHashes(new MemoryStream(input), hashTypes); + + #endregion + #region Stream Hashes ///