本文整理汇总了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();
}
示例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();
}