Skip to content

Commit

Permalink
[Hash] Revert Generic boxing on Hash creation methods
Browse files Browse the repository at this point in the history
  • Loading branch information
neon-nyan committed Jan 18, 2025
1 parent 0790696 commit 8effb69
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
12 changes: 6 additions & 6 deletions CollapseLauncher/Classes/Helper/Hash.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static partial class Hash
/// <typeparam name="T">The type of the hash algorithm to create. Must inherit from <see cref="HashAlgorithm"/>.</typeparam>
/// <returns>An instance of the specified hash algorithm.</returns>
/// <exception cref="NotSupportedException">Thrown when the specified hash algorithm type is not supported.</exception>
public static T CreateCryptoHash<T>()
public static HashAlgorithm CreateCryptoHash<T>()
where T : HashAlgorithm
{
// Try to get the hash create method from the dictionary
Expand All @@ -75,7 +75,7 @@ public static T CreateCryptoHash<T>()
}

// Create the hash algorithm instance
return (T)createHashDelegate();
return createHashDelegate();
}

/// <summary>
Expand All @@ -85,7 +85,7 @@ public static T CreateCryptoHash<T>()
/// <param name="key">The key to use for the HMAC-based hash algorithm.</param>
/// <returns>An instance of the specified HMAC-based hash algorithm.</returns>
/// <exception cref="NotSupportedException">Thrown when the specified HMAC-based hash algorithm type is not supported.</exception>
public static T CreateHmacCryptoHash<T>(byte[] key)
public static HashAlgorithm CreateHmacCryptoHash<T>(byte[] key)
where T : HashAlgorithm
{
// Try to get the hash create method from the dictionary
Expand All @@ -99,16 +99,16 @@ public static T CreateHmacCryptoHash<T>(byte[] key)
}

// Create the hash algorithm instance
return (T)createHashDelegate(key);
return createHashDelegate(key);
}

/// <summary>
/// Creates an instance of the specified non-cryptographic hash algorithm.
/// </summary>
/// <typeparam name="T">The type of the non-cryptographic hash algorithm to create. Must inherit from <see cref="NonCryptographicHashAlgorithm"/> and have a parameterless constructor.</typeparam>
/// <returns>An instance of the specified non-cryptographic hash algorithm.</returns>
public static T CreateHash<T>()
where T : NonCryptographicHashAlgorithm, new() => new();
public static NonCryptographicHashAlgorithm CreateHash<T>()
where T : NonCryptographicHashAlgorithm, new() => new T();

/// <summary>
/// Gets the shared hash algorithm instance of the specified non-cryptographic hash algorithm.
Expand Down
3 changes: 2 additions & 1 deletion InnoSetupHelper/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"resolved": "9.0.0",
"contentHash": "seeO8icDfED/Qwl9PDFUx2Gf/7xv7dPsMnw5PnRwNZuz4EWMpy0wIVohC4MfCcTIoJgp+KUrWG4WH3NPSusQOA=="
}
}
},
"net9.0/win-x64": {}
}
}

0 comments on commit 8effb69

Please sign in to comment.