cryptix.math
Class BigInteger
java.lang.Object
|
+--cryptix.math.BigNum
|
+--cryptix.math.BigInteger
- All Implemented Interfaces:
- java.lang.Cloneable
- public class BigInteger
- extends BigNum
A class implementing arbitrary-length integers.
java.math.BigInteger is preferred for new code.
Copyright © 1995-1997
Systemics Ltd on behalf of the
Cryptix Development Team.
All rights reserved.
$Revision: 1.5 $
- Since:
- Cryptix 2.2
- Author:
- unattributed
Methods inherited from class cryptix.math.BigNum |
add_unsigned, add_unsigned, add, add, assign, bignum_hashCode, bit, bitLength, byteLength, check_state, cmp, copy, dec, display, display, div, div, euclid, even, extended_euclid, fromBinary, gcd, grow, inc, intoBinary, inverseModN, isOne, isZero, mod, modExp, modMul, modMulRecip, mul, odd, one, recip, shiftLeft, shiftLeft, shiftLeftOnce, shiftRight, shiftRight, shiftRightOnce, sub_unsigned, sub_unsigned, sub, sub, ucmp, zero |
Methods inherited from class java.lang.Object |
getClass, hashCode, notify, notifyAll, wait, wait, wait |
zero
public static final BigInteger zero
one
public static final BigInteger one
BigInteger
public BigInteger()
BigInteger
public BigInteger(int from)
BigInteger
public BigInteger(BigInteger from)
BigInteger
public BigInteger(java.lang.String hexString)
BigInteger
public BigInteger(byte[] buffer)
static void ()
bitLength
public int bitLength()
clone
public java.lang.Object clone()
- Overrides:
clone
in class BigNum
copy
public void copy(java.lang.Object src)
- Overrides:
copy
in class BigNum
assign
public BigInteger assign(BigInteger n)
assign
public BigInteger assign(int n)
fromString
public void fromString(java.lang.String inHex)
toString
public java.lang.String toString()
- Overrides:
toString
in class java.lang.Object
finalize
protected void finalize()
- Overrides:
finalize
in class BigNum
modExp
public BigInteger modExp(BigInteger power,
BigInteger modulo)
inverseModN
public BigInteger inverseModN(BigInteger a,
BigInteger n)
mod
public BigInteger mod(BigInteger a,
BigInteger b)
mul
public BigInteger mul(BigInteger a,
BigInteger b)
div
public BigInteger div(BigInteger a,
BigInteger b)
add
public BigInteger add(BigInteger a,
BigInteger b)
add
public BigInteger add(int a)
sub
public BigInteger sub(BigInteger a,
BigInteger b)
gcd
public BigInteger gcd(BigNum a,
BigNum b)
cmp
public int cmp(BigInteger a)
equals
public boolean equals(java.lang.Object o)
- Tests whether another object is equal to this one.
Note: since BigIntegers are mutable, it was a mistake to override
equals. Also, equals
and hashCode
should
always be overridden together.
- Overrides:
equals
in class java.lang.Object
- Parameters:
obj
- object to test- Returns:
- true if the object is equal, otherwise false.
inc
public BigInteger inc()
dec
public BigInteger dec()
shiftLeft
public BigInteger shiftLeft(int n)
shiftRight
public BigInteger shiftRight(int n)
zero
public static BigInteger zero()
newBuffer
protected static byte[] newBuffer(int bitLen)
- An internal function to create a buffer big enough in which
to store a number.
- Parameters:
bitLen
- The number of bits in the number.- Returns:
- a buffer in which to store a number.
toByteArray
public byte[] toByteArray()
- Convert a number into a byte array.
- Returns:
- a byte array.
fromByteArray
public void fromByteArray(byte[] buf)
toJavaMathBigInteger
public java.math.BigInteger toJavaMathBigInteger()
- Convert this cryptix.math.BigInteger to a java.math.BigInteger.
- Returns:
- the java.math.BigInteger
fromJavaMathBigInteger
public static BigInteger fromJavaMathBigInteger(java.math.BigInteger from)
- Convert from a java.math.BigInteger to a cryptix.math.BigInteger.
- Parameters:
from
- the java.math.BigInteger- Returns:
- the cryptix.math.BigInteger
main
public static void main(java.lang.String[] args)
self_test
public static void self_test(java.io.PrintWriter out)
throws java.lang.Exception