Skip to content

Commit

Permalink
Use newer SHA256 API for .NET 8
Browse files Browse the repository at this point in the history
  • Loading branch information
drewnoakes committed Nov 11, 2024
1 parent 7035fbb commit 163aa88
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,15 @@ public string HashValue(string value)
}

byte[] inputBytes = Encoding.UTF8.GetBytes(value);

#if NET8_0_OR_GREATER
byte[] hash = SHA256.HashData(inputBytes);
#else
using var cryptoServiceProvider = SHA256.Create();
return BitConverter.ToString(cryptoServiceProvider.ComputeHash(inputBytes));
byte[] hash = cryptoServiceProvider.ComputeHash(inputBytes);
#endif

return BitConverter.ToString(hash);
}

private class TelemetryOperation : ITelemetryOperation
Expand Down

0 comments on commit 163aa88

Please sign in to comment.