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


C# BigInteger.ToArray方法代码示例

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


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

示例1: SRP6a

        public SRP6a(Account account)
        {
            this.Account = account;
            this.IdentitySalt = H.ComputeHash(Encoding.ASCII.GetBytes(this.Account.Email)).ToHexString(); // Identity salt that's hashed using account email.

            // calculate server's public ephemeral value.
            this.b = GetRandomBytes(128).ToBigInteger(); // server's secret ephemeral value.
            var gModb = BigInteger.ModPow(g, b, N); // pow(g, b, N)
            var k = H.ComputeHash(new byte[0].Concat(N.ToArray()).Concat(g.ToArray()).ToArray()).ToBigInteger(); // Multiplier parameter (k = H(N, g) in SRP-6a
            this.B = BigInteger.Remainder((this.Account.PasswordVerifier.ToBigInteger() * k) + gModb, N); // B = (k * v + pow(g, b, N)) % N

            // cook the logon challenge message
            this.LogonChallenge = new byte[0]
                .Concat(new byte[] { 0 }) // command = 0
                .Concat(this.IdentitySalt.ToByteArray()) // identity-salt - generated by hashing account email.
                .Concat(this.Account.Salt) // account-salt - generated on account creation.
                .Concat(B.ToArray()) // server's public ephemeral value (B)
                .Concat(SecondChallenge.ToArray()) // second challenge
                .ToArray();
        }
开发者ID:fasbat,项目名称:mooege,代码行数:20,代码来源:SRP6a.cs

示例2: SRP

        public SRP(string account, string password)
        {
            m_account = account;

            // workaround...
            m_accountSalt = HASH.ComputeHash(Encoding.ASCII.GetBytes(account)).ToHexString();

            var sBytes = GetRandomBytes(32);
            s = sBytes.ToPosBigInteger();

            var IBytes = HASH.ComputeHash(Encoding.ASCII.GetBytes(m_accountSalt.ToUpper() + ":" + password.ToUpper()));
            I = IBytes.ToPosBigInteger();

            var xBytes = HASH.ComputeHash(new byte[0]
                .Concat(sBytes)
                .Concat(IBytes)
                .ToArray());

            var x = xBytes.ToPosBigInteger();

            v = BigInteger.ModPow(g, x, N);

            b = GetRandomBytes(128).ToPosBigInteger();

            var gMod = BigInteger.ModPow(g, b, N);

            var kBytes = HASH.ComputeHash(new byte[0]
                .Concat(NBytes)
                .Concat(gBytes)
                .ToArray());

            var k = kBytes.ToPosBigInteger();

            B = BigInteger.Remainder((v * k) + gMod, N);

            var secondChallengeBytes1 = GetRandomBytes(128);
            m_secondChallengeServer1 = Extensions.ToPosBigInteger(secondChallengeBytes1);

            Response1 = new byte[0]
                .Concat(new byte[] { 0 }) // command == 0
                .Concat(m_accountSalt.ToByteArray()) // accountSalt
                .Concat(sBytes) // passwordSalt
                .Concat(B.ToArray()) // serverChallenge
                .Concat(secondChallengeBytes1) // secondaryChallenge
                .ToArray();
        }
开发者ID:Geracl,项目名称:d3proto,代码行数:46,代码来源:SRP.cs


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