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


C# BigInteger.ToHexString方法代码示例

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


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

示例1: 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

示例2: GenerateSignature

 //подписываем сообщение
 public string GenerateSignature(byte[] h, BigInteger d)
 {
     BigInteger alpha = new BigInteger(h);
     BigInteger e = alpha % n;
     if (e == 0)
         e = 1;
     BigInteger k = new BigInteger();
     ECPoint C = new ECPoint();
     BigInteger r = new BigInteger();
     BigInteger s = new BigInteger();
     do
     {
         do
         {
             k.genRandomBits(n.bitCount(), new Random());
         } while ((k < 0) || (k > n));
         C = ECPoint.multiply(k, G);
         r = C.x % n;
         s = ((r * d) + (k * e)) % n;
     } while ((r == 0) || (s == 0));
     string Rvector = padding(r.ToHexString(), n.bitCount() / 4);
     string Svector = padding(s.ToHexString(), n.bitCount() / 4);
     return Rvector + Svector;
 }
开发者ID:msCube,项目名称:Scrambler,代码行数:25,代码来源:CryptosystemBasedOnEllipticCurves.cs


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