Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use new MD5/SHA.HashData(Stream) overload #6177

Merged
merged 2 commits into from Feb 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 2 additions & 10 deletions osu.Framework/Extensions/ExtensionMethods.cs
Expand Up @@ -265,13 +265,8 @@ private static string toLowercaseHex(this byte[] bytes)
/// <returns>A lower-case hex string representation of the hash (64 characters).</returns>
public static string ComputeSHA2Hash(this Stream stream)
{
string hash;

stream.Seek(0, SeekOrigin.Begin);

using (var alg = SHA256.Create())
hash = alg.ComputeHash(stream).toLowercaseHex();

string hash = SHA256.HashData(stream).toLowercaseHex();
stream.Seek(0, SeekOrigin.Begin);

return hash;
Expand All @@ -286,11 +281,8 @@ public static string ComputeSHA2Hash(this Stream stream)

public static string ComputeMD5Hash(this Stream stream)
{
string hash;

stream.Seek(0, SeekOrigin.Begin);
using (var md5 = MD5.Create())
hash = md5.ComputeHash(stream).toLowercaseHex();
string hash = MD5.HashData(stream).toLowercaseHex();
stream.Seek(0, SeekOrigin.Begin);

return hash;
Expand Down