Skip to content

Commit

Permalink
csharp: revert SecureCompare implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
esskar committed Jan 5, 2025
1 parent f703640 commit 93e6b76
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions csharp/Svix/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static bool SecureCompare(string a, string b)
// Borrowed from Stripe-dotnet https://github.com/stripe/stripe-dotnet/blob/7b62c461d7c0cf2c9e06dce5e564b374a9d232e0/src/Stripe.net/Infrastructure/StringUtils.cs#L30
// basically identical to SecureCompare from Rails::ActiveSupport used in our ruby lib
[MethodImpl(MethodImplOptions.NoOptimization)]
public static bool SecureCompare<T>(ReadOnlySpan<T> a, ReadOnlySpan<T> b) where T : IComparable<T>
public static bool SecureCompare(ReadOnlySpan<char> a, ReadOnlySpan<char> b)
{
if (a.Length != b.Length)
{
Expand All @@ -25,7 +25,7 @@ public static bool SecureCompare<T>(ReadOnlySpan<T> a, ReadOnlySpan<T> b) where
var result = 0;
for (var i = 0; i < a.Length; i++)
{
result |= a[i].CompareTo(b[i]);
result |= a[i] ^b[i];
}

return result == 0;
Expand Down

0 comments on commit 93e6b76

Please sign in to comment.