DocumentManager/Utils/PasswordHash.cs
/// <summary>
/// Compares two byte arrays in length-constant time. This comparison
/// method is used so that password hashes cannot be extracted from
/// on-line systems using a timing attack and then attacked off-line.
/// </summary>
/// <param name="a">The first byte array.</param>
/// <param name="b">The second byte array.</param>
/// <returns>True if both byte arrays are equal. False otherwise.</returns>
Compares two byte arrays in length-constant time. This comparison
method is used so that password hashes cannot be extracted from
on-line systems using a timing attack and then attacked off-line.
Compares two byte arrays in length - constant time . This comparison method is used so that password hashes cannot be extracted from on - line systems using a timing attack and then attacked off - line .
private static bool SlowEquals(byte[] a, byte[] b) {
			uint diff = (uint)a.Length ^ (uint)b.Length;
			for (int i = 0; i < a.Length && i < b.Length; i++)
				diff |= (uint)(a[i] ^ b[i]);
			return diff == 0;
		}
private static bool SlowEquals ( byte [ ] a , byte [ ] b ) { uint diff = ( uint ) a . Length ^ ( uint ) b . Length ; for ( int i = 0 ; i < a . Length && i < b . Length ; i ++ ) diff |= ( uint ) ( a [ i ] ^ b [ i ] ) ; return diff == 0 ; }
Compares two byte arrays in length-constant time.
Compares two byte arrays in length - constant time .
True if both byte arrays are equal. False otherwise.
True if both byte arrays are equal . False otherwise .
a
byte[]
The first byte array.
The first byte array .
b
byte[]
The second byte array.
The second byte array .