本文整理汇总了C#中BigInteger.ToByteArrayUnsigned方法的典型用法代码示例。如果您正苦于以下问题:C# BigInteger.ToByteArrayUnsigned方法的具体用法?C# BigInteger.ToByteArrayUnsigned怎么用?C# BigInteger.ToByteArrayUnsigned使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BigInteger
的用法示例。
在下文中一共展示了BigInteger.ToByteArrayUnsigned方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Encode
internal static void Encode(
BcpgOutputStream bcpgOut,
BigInteger val)
{
bcpgOut.WriteShort((short) val.BitLength);
bcpgOut.Write(val.ToByteArrayUnsigned());
}
示例2: ECPrivateKeyStructure
public ECPrivateKeyStructure(
BigInteger key)
{
if (key == null)
throw new ArgumentNullException("key");
this.seq = new DerSequence(
new DerInteger(1),
new DerOctetString(key.ToByteArrayUnsigned()));
}
示例3: IntegerToBytes
public static byte[] IntegerToBytes(
BigInteger s,
int qLength)
{
byte[] bytes = s.ToByteArrayUnsigned();
if (qLength < bytes.Length)
{
byte[] tmp = new byte[qLength];
Array.Copy(bytes, bytes.Length - tmp.Length, tmp, 0, tmp.Length);
return tmp;
}
else if (qLength > bytes.Length)
{
byte[] tmp = new byte[qLength];
Array.Copy(bytes, 0, tmp, tmp.Length - bytes.Length, bytes.Length);
return tmp;
}
return bytes;
}
示例4: IntArray
public IntArray(BigInteger bigInt, int minIntLen)
{
if (bigInt.SignValue == -1)
throw new ArgumentException("Only positive Integers allowed", "bigint");
if (bigInt.SignValue == 0)
{
m_ints = new int[] { 0 };
return;
}
byte[] barr = bigInt.ToByteArrayUnsigned();
int barrLen = barr.Length;
int intLen = (barrLen + 3) / 4;
m_ints = new int[System.Math.Max(intLen, minIntLen)];
int rem = barrLen % 4;
int barrI = 0;
if (0 < rem)
{
int temp = (int) barr[barrI++];
while (barrI < rem)
{
temp = temp << 8 | (int) barr[barrI++];
}
m_ints[--intLen] = temp;
}
while (intLen > 0)
{
int temp = (int) barr[barrI++];
for (int i = 1; i < 4; i++)
{
temp = temp << 8 | (int) barr[barrI++];
}
m_ints[--intLen] = temp;
}
}
示例5: ConvertOutput
public byte[] ConvertOutput(
BigInteger result)
{
byte[] output = result.ToByteArrayUnsigned();
if (forEncryption)
{
int outSize = GetOutputBlockSize();
// TODO To avoid this, create version of BigInteger.ToByteArray that
// writes to an existing array
if (output.Length < outSize) // have ended up with less bytes than normal, lengthen
{
byte[] tmp = new byte[outSize];
output.CopyTo(tmp, tmp.Length - output.Length);
output = tmp;
}
}
return output;
}
示例6: AsUnsignedByteArray
/**
* Return the passed in value as an unsigned byte array.
*
* @param value value to be converted.
* @return a byte array without a leading zero byte if present in the signed encoding.
*/
public static byte[] AsUnsignedByteArray(
BigInteger n)
{
return n.ToByteArrayUnsigned();
}