本文整理汇总了C#中BigInteger.ToHexString方法的典型用法代码示例。如果您正苦于以下问题:C# BigInteger.ToHexString方法的具体用法?C# BigInteger.ToHexString怎么用?C# BigInteger.ToHexString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BigInteger
的用法示例。
在下文中一共展示了BigInteger.ToHexString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SignGen
//подписываем сообщение
public string SignGen(byte[] h, BigInteger d)
{
alpha = new BigInteger(h);
e = alpha % n;
if (e == 0)
e = 1;
k = new BigInteger();
C = new ECPoint();
r = new 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;
}
示例2: 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(Resources.nlsServerProof20);
MemoryStream ms_m2 = new MemoryStream(92);
BinaryWriter bw = new BinaryWriter(ms_m2);
bw.Write(EnsureArrayLength(A.GetBytes(), 32));
bw.Write(m1.GetBytes());
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);
}
示例3: genDS
//формирование цифровой подписи.
public string genDS(byte[] h, BigInteger d)
{
BigInteger a = new BigInteger(h);
BigInteger e = a % n;
if (e == 0)
e = 1;
BigInteger k = new BigInteger();
CECPoint C=new CECPoint();
BigInteger r=new BigInteger();
BigInteger s = new BigInteger();
do
{
do
{
k.genRandomBits(n.bitCount(), new Random());
}
while ((k < 0) || (k > n));
C = CECPoint.multiply(G, k);
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;
}