//http://www.bouncycastle.org/
//MIT X11 License
using System;
using System.Text;
namespace Org.BouncyCastle.Utilities
{
/// <summary> General array utilities.</summary>
public sealed class Arrays
{
private static bool HaveSameContents(byte[] a,byte[] b)
{
if (a.Length != b.Length)
return false;
for (int i = 0; i < a.Length; i++)
{
if (a[i] != b[i])
return false;
}
return true;
}
private static bool HaveSameContents(int[] a,int[] b)
{
if (a.Length != b.Length)
return false;
for (int i = 0; i < a.Length; i++)
{
if (a[i] != b[i])
return false;
}
return true;
}
/// <summary>
/// Are two arrays equal.
/// </summary>
/// <param name="a">Left side.</param>
/// <param name="b">Right side.</param>
/// <returns>True if equal.</returns>
public static bool AreEqual(byte[] a,byte[] b)
{
if (a == b)
return true;
if (a == null || b == null)
return false;
return HaveSameContents(a, b);
}
[Obsolete("Use 'AreEqual' method instead")]
public static bool AreSame(byte[] a,byte[] b)
{
return AreEqual(a, b);
}
public static bool AreEqual(int[] a,int[] b)
{
if (a == b)
return true;
if (a == null || b == null)
return false;
return HaveSameContents(a, b);
}
}
}
|