当前位置: 首页>>代码示例>>C#>>正文


C# BigInteger.Equals方法代码示例

本文整理汇总了C#中System.Numerics.BigInteger.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# BigInteger.Equals方法的具体用法?C# BigInteger.Equals怎么用?C# BigInteger.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Numerics.BigInteger的用法示例。


在下文中一共展示了BigInteger.Equals方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: facto

 static BigInteger facto(BigInteger num)
 {
     if (num < 0)
         return 0;
     else if (num.Equals(0))
         return 1;
     else
         return num * facto(num - 1);
 }
开发者ID:joshjohn1984,项目名称:HackerRankSolutions,代码行数:9,代码来源:ExtraLongFactorials.cs

示例2: Multiply

        public Point Multiply(Point p, BigInteger x)
        {
            if (x.Equals(BigInteger.Zero)) return p.Curve.Infinity;

            if ((x % 2).Equals(BigInteger.One))
            {
                return p + Multiply(p, x - 1);
            }

            return Multiply(p + p, x / 2);
        }
开发者ID:hypesystem,项目名称:OpenECC,代码行数:11,代码来源:DoubleAndAddPointMultiplier.cs

示例3: FindBySerialNumber

        public void FindBySerialNumber(BigInteger hexValue, BigInteger decimalValue)
        {
            FindCore(
                cert =>
                {
                    byte[] serialBytes = cert.GetSerialNumber();
                    BigInteger serialNumber = FindPal.PositiveBigIntegerFromByteArray(serialBytes);
                    bool match = hexValue.Equals(serialNumber) || decimalValue.Equals(serialNumber);

                    return match;
                });
        }
开发者ID:Corillian,项目名称:corefx,代码行数:12,代码来源:OpenSslCertificateFinder.cs

示例4: ExpMod

 private static BigInteger ExpMod(BigInteger number, BigInteger exponent, BigInteger modulo)
 {
     if (exponent.Equals(BigInteger.Zero))
     {
         return BigInteger.One;
     }
     BigInteger t = BigInteger.Pow(ExpMod(number, exponent / Two, modulo), 2).Mod(modulo);
     if (!exponent.IsEven)
     {
         t *= number;
         t = t.Mod(modulo);
     }
     return t;
 }
开发者ID:hanswolff,项目名称:ed25519,代码行数:14,代码来源:Ed25519.cs

示例5: ScalarMul

 private static Tuple<BigInteger, BigInteger> ScalarMul(Tuple<BigInteger, BigInteger> p, BigInteger e)
 {
     if (e.Equals(BigInteger.Zero))
     {
         return new Tuple<BigInteger, BigInteger>(BigInteger.Zero, BigInteger.One);
     }
     var q = ScalarMul(p, e / Two);
     q = EdwardsSquare(q.Item1, q.Item2);
     if (!e.IsEven) q = Edwards(q.Item1, q.Item2, p.Item1, p.Item2);
     return q;
 }
开发者ID:hanswolff,项目名称:ed25519,代码行数:11,代码来源:Ed25519.cs

示例6: DefaultCtorWorks

		public void DefaultCtorWorks ()
		{
			var a = new BigInteger ();
			Assert.AreEqual (BigInteger.One, ++a, "#1");

			a = new BigInteger ();
			Assert.AreEqual (BigInteger.MinusOne, --a, "#2");

			a = new BigInteger ();
			Assert.AreEqual (BigInteger.MinusOne, ~a, "#3");

			a = new BigInteger ();
			Assert.AreEqual ("0", a.ToString (), "#4");

			a = new BigInteger ();
			Assert.AreEqual (true, a == a, "#5");

			a = new BigInteger ();
			Assert.AreEqual (false, a < a, "#6");

			a = new BigInteger ();
			Assert.AreEqual (true, a < 10l, "#7");

			a = new BigInteger ();
			Assert.AreEqual (true, a.IsEven, "#8");

			a = new BigInteger ();
			Assert.AreEqual (0, (int)a, "#9");

			a = new BigInteger ();
			Assert.AreEqual (0, (uint)a, "#10");

			a = new BigInteger ();
			Assert.AreEqual (0, (ulong)a, "#11");

			a = new BigInteger ();
			Assert.AreEqual (true, a.Equals (a), "#12");

			a = new BigInteger ();
			Assert.AreEqual (a, BigInteger.Min (a, a), "#13");

			a = new BigInteger ();
			Assert.AreEqual (a, BigInteger.GreatestCommonDivisor (a, a), "#14");

			a = new BigInteger ();
			Assert.AreEqual (BigInteger.Zero.GetHashCode (), a.GetHashCode (), "#15");
		}
开发者ID:koush,项目名称:mono,代码行数:47,代码来源:BigIntegerTest.cs

示例7: ReKeyBuddyKeys

        private void ReKeyBuddyKeys(UInt32 buddy_key_id, BigInteger buddy_public_key)
        {
            /*is it the same public key we know?   */
            if (buddy_public_key.Equals(_my_buddy_recent_dh_public_key))
                return;

            _my_buddy_old_dh_public_key = _my_buddy_recent_dh_public_key;
            _my_buddy_recent_dh_public_key = buddy_public_key;

            _my_buddy_old_dh_public_key_id = _my_buddy_recent_dh_public_key_id;
            _my_buddy_recent_dh_public_key_id++;
        }
开发者ID:zamud,项目名称:OTRLib,代码行数:12,代码来源:OTRSession.cs

示例8: VerifyServerProof

        /// <summary>
        /// Verifies that the server's proof value matches the value
        /// calculated by the client.
        /// </summary>
        /// <param name="serverProof">The 20-byte server proof.</param>
        /// <exception cref="ArgumentOutOfRangeException">Thrown if 
        /// the server proof value is not exactly 20 bytes.</exception>
        /// <exception cref="InvalidOperationException">Thrown if the object has not 
        /// yet been initialized.</exception>
        /// <remarks>
        /// This method should be called after the <see cref="LoginProof(byte[], int, int, byte[], byte[])">LoginProof</see> method.
        /// </remarks>
        /// <returns><b>True</b> if the server proof is valid; 
        /// otherwise <b>false</b>.</returns>
        public bool VerifyServerProof(byte[] serverProof)
        {
            if (serverProof.Length != 20)
                throw new ArgumentOutOfRangeException("Server proof must be exactly 20 bytes.");

            using (MemoryStream ms_m2 = new MemoryStream(92))
            {
                BinaryWriter bw = new BinaryWriter(ms_m2);
                bw.Write(EnsureArrayLength(A.ToByteArray(), 32));
                bw.Write(m1.ToByteArray());
                bw.Write(k);
                byte[] client_m2_data = ms_m2.GetBuffer();
                ms_m2.Close();

                byte[] client_hash_m2 = s_sha.ComputeHash(client_m2_data);
                BigInteger client_m2 = new BigInteger(client_hash_m2);
                BigInteger server_m2 = new BigInteger(serverProof);

                Debug.WriteLine(client_m2.ToHexString(), "Client");
                Debug.WriteLine(server_m2.ToHexString(), "Server");

                return client_m2.Equals(server_m2);
            }
        }
开发者ID:Mofsy,项目名称:jinxbot,代码行数:38,代码来源:NLS.cs

示例9: ValidateServerSignature

        /// <summary>
        /// Validates a Warcraft III server signature.
        /// </summary>
        /// <param name="serverSignature">The server signature from 
        /// Battle.net's SID_AUTH_INFO message.</param>
        /// <param name="ipAddress">The IPv4 address of the server
        /// currently connected-to.</param>
        /// <returns><b>True</b> if the signature matches; 
        /// otherwise <b>false</b>.</returns>
        /// <exception cref="ArgumentOutOfRangeException">Thrown if 
        /// the server signature is not exactly 128 bytes.</exception>
        public static bool ValidateServerSignature(byte[] serverSignature,
            byte[] ipAddress)
        {
            // code based on iago's code.

            if (serverSignature.Length != 128)
                throw new ArgumentOutOfRangeException("The server signature must be exactly 128 bytes long.");

            BigInteger key = new BigInteger(new byte[] { 0, 1, 0, 1 } /* ReverseArray(new BigInteger((ulong)SignatureKey).GetBytes()) */);
            BigInteger mod = BigInteger.Parse(ServerModulus, NumberStyles.HexNumber);
            BigInteger sig = new BigInteger(ReverseArray(serverSignature));

            byte[] result = BigInteger.ModPow(sig, key, mod).ToByteArray();
            BigInteger res = new BigInteger(ReverseArray(result));

            using (MemoryStream ms_res = new MemoryStream(result.Length))
            {
                ms_res.Write(ipAddress, 0, 4);
                for (int i = 4; i < result.Length; i++)
                    ms_res.WriteByte(0xbb);

                ms_res.Seek(-1, SeekOrigin.Current);
                ms_res.WriteByte(0x0b);

                BigInteger cor_res = new BigInteger(ms_res.GetBuffer());
                return cor_res.Equals(res);
            }

            
        }
开发者ID:Mofsy,项目名称:jinxbot,代码行数:41,代码来源:NLS.cs

示例10: FindBySerialNumber

        public unsafe void FindBySerialNumber(BigInteger hexValue, BigInteger decimalValue)
        {
            FindCore(
                delegate(SafeCertContextHandle pCertContext)
                {
                    byte[] actual = pCertContext.CertContext->pCertInfo->SerialNumber.ToByteArray();
                    GC.KeepAlive(pCertContext);

                    // Convert to BigInteger as the comparison must not fail due to spurious leading zeros
                    BigInteger actualAsBigInteger = PositiveBigIntegerFromByteArray(actual);

                    return hexValue.Equals(actualAsBigInteger) || decimalValue.Equals(actualAsBigInteger);
                });
        }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:14,代码来源:FindPal.cs


注:本文中的System.Numerics.BigInteger.Equals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。