static Integer[] Integers(int size) { var values = new Integer[ValCount]; for (var i = 0; i < ValCount; i++) { values[i] = IntegerConverter.FromByteArray(RandomBytes(size)); } return(values); }
public LargeInteger(byte[] bytes) { if (bytes != null) { if (bytes[0] > 127) { bytes = ByteManipulator.BigEndianTruncate(bytes, bytes.Length + 1); //add big endian padding to get only positive numbers } if (BitConverter.IsLittleEndian) { bytes = bytes.Reverse().ToArray(); } value = IntegerConverter.FromByteArray(bytes); } else { value = 0; } }
public static void FromByteArrayNull() { Assert.Throws <ArgumentNullException>(() => IntegerConverter.FromByteArray(null)); }
public void FromByteArray(byte[] value, Integer expected) { var actual = IntegerConverter.FromByteArray(value); Assert.Equal(expected, actual); }
protected Integer ToInteger(BigInteger value) { return(IntegerConverter.FromByteArray(value.ToByteArray())); }