System.Security.Cryptography.TripleDES.EqualBytes C# (CSharp) Метод

EqualBytes() приватный статический Метод

private static EqualBytes ( byte rgbKey, int start1, int start2, int count ) : bool
rgbKey byte
start1 int
start2 int
count int
Результат bool
        private static bool EqualBytes(byte[] rgbKey, int start1, int start2, int count)
        {
            Debug.Assert(start1 >= 0);
            Debug.Assert(start2 >= 0);
            Debug.Assert((start1 + count) <= rgbKey.Length);
            Debug.Assert((start2 + count) <= rgbKey.Length);

            for (int i = 0; i < count; i++)
            {
                if (rgbKey[start1 + i] != rgbKey[start2 + i])
                    return false;
            }
            return true;
        }

Usage Example

Пример #1
0
 /// <summary>Determines whether the specified key is weak.</summary>
 /// <param name="rgbKey">The secret key to test for weakness. </param>
 /// <returns>
 ///     <see langword="true" /> if the key is weak; otherwise, <see langword="false" />.</returns>
 /// <exception cref="T:System.Security.Cryptography.CryptographicException">The size of the <paramref name="rgbKey" /> parameter is not valid. </exception>
 // Token: 0x060023CB RID: 9163 RVA: 0x000824C8 File Offset: 0x000806C8
 public static bool IsWeakKey(byte[] rgbKey)
 {
     if (!TripleDES.IsLegalKeySize(rgbKey))
     {
         throw new CryptographicException(Environment.GetResourceString("Cryptography_InvalidKeySize"));
     }
     byte[] array = Utils.FixupKeyParity(rgbKey);
     return(TripleDES.EqualBytes(array, 0, 8, 8) || (array.Length == 24 && TripleDES.EqualBytes(array, 8, 16, 8)));
 }