System.Security.Cryptography.DES.QuadWordFromBigEndian C# (CSharp) Method

QuadWordFromBigEndian() private static method

private static QuadWordFromBigEndian ( byte block ) : UInt64
block byte
return UInt64
        private static UInt64 QuadWordFromBigEndian(byte[] block)
        {
            UInt64 x = (
                (((UInt64)block[0]) << 56) | (((UInt64)block[1]) << 48) |
                (((UInt64)block[2]) << 40) | (((UInt64)block[3]) << 32) |
                (((UInt64)block[4]) << 24) | (((UInt64)block[5]) << 16) |
                (((UInt64)block[6]) << 8) | ((UInt64)block[7])
                );
            return x;
        }

Usage Example

Example #1
0
        /// <summary>确定指定的密钥是否为半弱密钥。</summary>
        /// <returns>如果该密钥为半弱密钥,则为 true;否则,为 false。</returns>
        /// <param name="rgbKey">要进行半弱漏洞测试的机密密钥。</param>
        /// <exception cref="T:System.Security.Cryptography.CryptographicException">
        /// <paramref name="rgbKey" /> 参数的大小无效。</exception>
        public static bool IsSemiWeakKey(byte[] rgbKey)
        {
            if (!DES.IsLegalKeySize(rgbKey))
            {
                throw new CryptographicException(Environment.GetResourceString("Cryptography_InvalidKeySize"));
            }
            switch (DES.QuadWordFromBigEndian(Utils.FixupKeyParity(rgbKey)))
            {
            case 143554428589179390:
            case 18303189645120372225:
            case 2296870857142767345:
            case 16149873216566784270:
            case 135110050437988849:
            case 16141428838415593729:
            case 2305315235293957886:
            case 18311634023271562766:
            case 80784550989267214:
            case 2234100979542855169:
            case 16212643094166696446:
            case 18365959522720284401:
                return(true);

            default:
                return(false);
            }
        }
All Usage Examples Of System.Security.Cryptography.DES::QuadWordFromBigEndian