ActionScript 3 Cryptography Library | All Packages | All Classes | Index | Frames No Frames |
BigInteger

Package | com.hurlant.math
Class | public class BigInteger
Inheritance | BigInteger Object
Subclasses | Integer

Public Properties

| Property | Defined By
--- | --- | ---
|  | t : int | BigInteger

Public Methods

| Method | Defined By
--- | --- | ---
|  | BigInteger(value:* = null, radix:int = 0, unsigned:Boolean = false) | BigInteger
|  | abs():BigInteger |this| | BigInteger
|  | add(a:BigInteger):BigInteger | BigInteger
|  | and(a:BigInteger):BigInteger | BigInteger
|  | andNot(a:BigInteger):BigInteger | BigInteger
|  | bitCount():int | BigInteger
|  | bitLength():int returns the number of bits in this | BigInteger
|  | byteValue():int | BigInteger
|  | clearBit(n:int):BigInteger | BigInteger
|  | clone():BigInteger | BigInteger
|  | compareTo(v:BigInteger):int return + if this > v, - if this < v, 0 if equal | BigInteger
|  | dispose():void | BigInteger
|  | divide(a:BigInteger):BigInteger | BigInteger
|  | divideAndRemainder(a:BigInteger):Array | BigInteger
|  | equals(a:BigInteger):Boolean | BigInteger
|  | flipBit(n:int):BigInteger | BigInteger
|  | gcd(a:BigInteger):BigInteger | BigInteger
|  | getLowestSetBit():int | BigInteger
|  | intValue():int | BigInteger
|  | isProbablePrime(t:int):Boolean | BigInteger
|  | max(a:BigInteger):BigInteger | BigInteger
|  | min(a:BigInteger):BigInteger | BigInteger
|  | mod(v:BigInteger):BigInteger | BigInteger
|  | modInverse(m:BigInteger):BigInteger | BigInteger
|  | modPow(e:BigInteger, m:BigInteger):BigInteger | BigInteger
|  | modPowInt(e:int, m:BigInteger):BigInteger this^e % m, 0 <= e < 2^32 | BigInteger
|  | multiply(a:BigInteger):BigInteger | BigInteger
|  | nbv(value:int):BigInteger [static] return bigint initialized to value | BigInteger
|  | negate():BigInteger -this | BigInteger
|  | not():BigInteger | BigInteger
|  | or(a:BigInteger):BigInteger | BigInteger
|  | pow(e:int):BigInteger | BigInteger
|  | primify(bits:int, t:int):void Tweak our BigInteger until it looks prime enough | BigInteger
|  | remainder(a:BigInteger):BigInteger | BigInteger
|  | setBit(n:int):BigInteger | BigInteger
|  | shiftLeft(n:int):BigInteger | BigInteger
|  | shiftRight(n:int):BigInteger | BigInteger
|  | shortValue():int | BigInteger
|  | sigNum():int | BigInteger
|  | subtract(a:BigInteger):BigInteger | BigInteger
|  | testBit(n:int):Boolean | BigInteger
|  | toArray(array:ByteArray):uint | BigInteger
|  | toByteArray():ByteArray | BigInteger
|  | toString(radix:Number = 16):String | BigInteger
|  | valueOf():Number best-effort attempt to fit into a Number. | BigInteger
|  | xor(a:BigInteger):BigInteger | BigInteger

Protected Methods

| Method | Defined By
--- | --- | ---
|  | addTo(a:BigInteger, r:BigInteger):void | BigInteger
|  | bitwiseTo(a:BigInteger, op:Function, r:BigInteger):void | BigInteger
|  | changeBit(n:int, op:Function):BigInteger | BigInteger
|  | chunkSize(r:Number):int | BigInteger
|  | fromRadix(s:String, b:int = 10):void | BigInteger
|  | millerRabin(t:int):Boolean | BigInteger
|  | modInt(n:int):int | BigInteger
|  | nbi():* | BigInteger
|  | toRadix(b:uint = 10):String | BigInteger

Public Constants

| Constant | Defined By
--- | --- | ---
|  | BI_FP : int = 52 [static] | BigInteger
|  | DB : int = 30 [static] | BigInteger
|  | DM : int [static] | BigInteger
|  | DV : int [static] | BigInteger
|  | F1 : int = 22.0 [static] | BigInteger
|  | F2 : int = 8.0 [static] | BigInteger
|  | FV : Number [static] | BigInteger
|  | lowprimes : Array [static] | BigInteger
|  | lplim : int [static] | BigInteger
|  | ONE : BigInteger [static] | BigInteger
|  | ZERO : BigInteger [static] | BigInteger

Property Detail

a | property

`bi_internal var a:Array`

s | property |

`bi_internal var s:int`

t | property |

`public var t:int`

Constructor Detail

BigInteger | () | Constructor

`public function BigInteger(value:* = null, radix:int = 0, unsigned:Boolean = false)`

Parameters

| `value:*` (default = `null`)``
| `radix:int` (default = `0`)`` — WARNING: If value is ByteArray, this holds the number of bytes to use.
| `unsigned:Boolean` (default = `false`)``

Method Detail

abs | () | method

`public function abs():BigInteger`

|this|

Returns

| `BigInteger`

add | () | method |

`public function add(a:BigInteger):BigInteger`

Parameters

| `a:BigInteger`

Returns

| `BigInteger` — this + a

addTo | () | method |

`protected function addTo(a:BigInteger, r:BigInteger):void`

Parameters

| `a:BigInteger`
| `r:BigInteger` — = this + a

am | () | method |

`bi_internal function am(i:int, x:int, w:BigInteger, j:int, c:int, n:int):int`

Parameters

| `i:int`
| `x:int`
| `w:BigInteger`
| `j:int`
| `c:int`
| `n:int`

Returns

| `int`

and | () | method |

`public function and(a:BigInteger):BigInteger`

Parameters

| `a:BigInteger`

Returns

| `BigInteger`

andNot | () | method |

`public function andNot(a:BigInteger):BigInteger`

Parameters

| `a:BigInteger`

Returns

| `BigInteger`

bitCount | () | method |

`public function bitCount():int`

Returns

| `int` — number of set bits

bitLength | () | method |

`public function bitLength():int`

returns the number of bits in this

Returns

| `int`

bitwiseTo | () | method |

`protected function bitwiseTo(a:BigInteger, op:Function, r:BigInteger):void`

Parameters

| `a:BigInteger` — a BigInteger to perform the operation with
| `op:Function` — a Function implementing the operation
| `r:BigInteger` — a BigInteger to store the result of the operation

byteValue | () | method |

`public function byteValue():int`

Returns

| `int` — value as byte

changeBit | () | method |

`protected function changeBit(n:int, op:Function):BigInteger`

Parameters

| `n:int`
| `op:Function`

Returns

| `BigInteger` —

chunkSize | () | method |

`protected function chunkSize(r:Number):int`

Parameters

| `r:Number`

Returns

| `int` —

clamp | () | method |

`bi_internal function clamp():void`

clamp off excess high words

clearBit | () | method |

`public function clearBit(n:int):BigInteger`

Parameters

| `n:int`

Returns

| `BigInteger` —

clone | () | method |

`public function clone():BigInteger`

Returns

| `BigInteger`

compareTo | () | method |

`public function compareTo(v:BigInteger):int`

Parameters

| `v:BigInteger`

Returns

| `int`

copyTo | () | method |

`bi_internal function copyTo(r:BigInteger):void`

copy this to r

Parameters

| `r:BigInteger`

dAddOffset | () | method |

`bi_internal function dAddOffset(n:int, w:int):void`

Parameters

| `n:int`
| `w:int`

dispose | () | method |

`public function dispose():void`

divide | () | method |

`public function divide(a:BigInteger):BigInteger`

Parameters

| `a:BigInteger`

Returns

| `BigInteger` — this / a

divideAndRemainder | () | method |

`public function divideAndRemainder(a:BigInteger):Array`

Parameters

| `a:BigInteger`

Returns

| `Array` — [this/a, this%a]

divRemTo | () | method |

`bi_internal function divRemTo(m:BigInteger, q:BigInteger = null, r:BigInteger = null):void`

divide this by m, quotient and remainder to q, r (HAC 14.20) r != q, this != m. q or r may be null.

Parameters

| `m:BigInteger`
| `q:BigInteger` (default = `null`)``
| `r:BigInteger` (default = `null`)``

dlShiftTo | () | method |

`bi_internal function dlShiftTo(n:int, r:BigInteger):void`

Parameters

| `n:int`
| `r:BigInteger`

dMultiply | () | method |

`bi_internal function dMultiply(n:int):void`

Parameters

| `n:int`

drShiftTo | () | method |

`bi_internal function drShiftTo(n:int, r:BigInteger):void`

r = this >> nB

Parameters

| `n:int`
| `r:BigInteger`

equals | () | method |

`public function equals(a:BigInteger):Boolean`

Parameters

| `a:BigInteger`

Returns

| `Boolean`

exp | () | method |

`bi_internal function exp(e:int, z:IReduction):BigInteger`

Parameters

| `e:int`
| `z:IReduction`

Returns

| `BigInteger`

flipBit | () | method |

`public function flipBit(n:int):BigInteger`

Parameters

| `n:int`

Returns

| `BigInteger` —

fromArray | () | method |

`bi_internal function fromArray(value:ByteArray, length:int, unsigned:Boolean = false):void`

set from ByteArray and length, starting a current position If length goes beyond the array, pad with zeroes.

Parameters

| `value:ByteArray`
| `length:int`
| `unsigned:Boolean` (default = `false`)``

fromInt | () | method |

`bi_internal function fromInt(value:int):void`

Parameters

| `value:int`

fromRadix | () | method |

`protected function fromRadix(s:String, b:int = 10):void`

Parameters

| `s:String` — a string to convert from using radix.
| `b:int` (default = `10`)`` — a radix

gcd | () | method |

`public function gcd(a:BigInteger):BigInteger`

Parameters

| `a:BigInteger`

Returns

| `BigInteger` — gcd(this, a) (HAC 14.54)

getLowestSetBit | () | method |

`public function getLowestSetBit():int`

Returns

| `int` — index of lowest 1-bit (or -1 if none)

intAt | () | method |

`bi_internal function intAt(str:String, index:int):int`

Parameters

| `str:String`
| `index:int`

Returns

| `int`

intValue | () | method |

`public function intValue():int`

Returns

| `int` — value as integer

invDigit | () | method |

`bi_internal function invDigit():int`

return "-1/this % 2^DB"; useful for Mont. reduction justification: xy == 1 (mod n) xy = 1+km xy(2-xy) = (1+km)(1-km) x[y(2-xy)] = 1-k^2.m^2 x[y(2-xy)] == 1 (mod m^2) if y is 1/x mod m, then y(2-xy) is 1/x mod m^2 should reduce x and y(2-xy) by m^2 at each step to keep size bounded [XXX unit test the living shit out of this.]

Returns

| `int`

isEven | () | method |

`bi_internal function isEven():Boolean`

true iff this is even

Returns

| `Boolean`

isProbablePrime | () | method |

`public function isProbablePrime(t:int):Boolean`

Parameters

| `t:int`

Returns

| `Boolean` — primality with certainty >= 1-.5^t

lShiftTo | () | method |

`bi_internal function lShiftTo(n:int, r:BigInteger):void`

Parameters

| `n:int`
| `r:BigInteger`

max | () | method |

`public function max(a:BigInteger):BigInteger`

Parameters

| `a:BigInteger`

Returns

| `BigInteger`

millerRabin | () | method |

`protected function millerRabin(t:int):Boolean`

Parameters

| `t:int`

Returns

| `Boolean` — true if probably prime (HAC 4.24, Miller-Rabin)

min | () | method |

`public function min(a:BigInteger):BigInteger`

Parameters

| `a:BigInteger`

Returns

| `BigInteger`

mod | () | method |

`public function mod(v:BigInteger):BigInteger`

Parameters

| `v:BigInteger`

Returns

| `BigInteger` — this % v

modInt | () | method |

`protected function modInt(n:int):int`

Parameters

| `n:int`

Returns

| `int` —

modInverse | () | method |

`public function modInverse(m:BigInteger):BigInteger`

Parameters

| `m:BigInteger`

Returns

| `BigInteger` — 1/this %m (HAC 14.61)

modPow | () | method |

`public function modPow(e:BigInteger, m:BigInteger):BigInteger`

Parameters

| `e:BigInteger`
| `m:BigInteger`

Returns

| `BigInteger` — this^e % m (HAC 14.85)

modPowInt | () | method |

`public function modPowInt(e:int, m:BigInteger):BigInteger`

Parameters

| `e:int`
| `m:BigInteger`

Returns

| `BigInteger`

multiply | () | method |

`public function multiply(a:BigInteger):BigInteger`

Parameters

| `a:BigInteger`

Returns

| `BigInteger` — this a

multiplyLowerTo | () | method |

`bi_internal function multiplyLowerTo(a:BigInteger, n:int, r:BigInteger):void`

Parameters

| `a:BigInteger`
| `n:int`
| `r:BigInteger`

multiplyTo | () | method |

`bi_internal function multiplyTo(v:BigInteger, r:BigInteger):void`

r = this v, r != this,a (HAC 14.12) "this" should be the larger one if appropriate

Parameters

| `v:BigInteger`
| `r:BigInteger`

multiplyUpperTo | () | method |

`bi_internal function multiplyUpperTo(a:BigInteger, n:int, r:BigInteger):void`

Parameters

| `a:BigInteger`
| `n:int`
| `r:BigInteger` — = "this a" without lower n words, n > 0

nbi | () | method |

`protected function nbi():*`

Returns

| `*`

nbits | () | method |

`bi_internal function nbits(x:int):int`

returns bit length of the integer x

Parameters

| `x:int`

Returns

| `int`

nbv | () | method |

`public static function nbv(value:int):BigInteger`

return bigint initialized to value

Parameters

| `value:int`

Returns

| `BigInteger`

negate | () | method |

`public function negate():BigInteger`

-this

Returns

| `BigInteger`

not | () | method |

`public function not():BigInteger`

Returns

| `BigInteger`

or | () | method |

`public function or(a:BigInteger):BigInteger`

Parameters

| `a:BigInteger`

Returns

| `BigInteger`

pow | () | method |

`public function pow(e:int):BigInteger`

Parameters

| `e:int`

Returns

| `BigInteger` — this^e

primify | () | method |

`public function primify(bits:int, t:int):void`

Tweak our BigInteger until it looks prime enough

Parameters

| `bits:int`
| `t:int`

remainder | () | method |

`public function remainder(a:BigInteger):BigInteger`

Parameters

| `a:BigInteger`

Returns

| `BigInteger`

rShiftTo | () | method |

`bi_internal function rShiftTo(n:int, r:BigInteger):void`

r = this >> n

Parameters

| `n:int`
| `r:BigInteger`

setBit | () | method |

`public function setBit(n:int):BigInteger`

Parameters

| `n:int`

Returns

| `BigInteger` —

shiftLeft | () | method |

`public function shiftLeft(n:int):BigInteger`

Parameters

| `n:int`

Returns

| `BigInteger`

shiftRight | () | method |

`public function shiftRight(n:int):BigInteger`

Parameters

| `n:int`

Returns

| `BigInteger`

shortValue | () | method |

`public function shortValue():int`

Returns

| `int` — value as short (assumes DB>=16)

sigNum | () | method |

`public function sigNum():int`

Returns

| `int` — 0 if this ==0, 1 if this >0

squareTo | () | method |

`bi_internal function squareTo(r:BigInteger):void`

r = this^2, r != this (HAC 14.16)

Parameters

| `r:BigInteger`

subTo | () | method |

`bi_internal function subTo(v:BigInteger, r:BigInteger):void`

r = this - v

Parameters

| `v:BigInteger`
| `r:BigInteger`

subtract | () | method |

`public function subtract(a:BigInteger):BigInteger`

Parameters

| `a:BigInteger`

Returns

| `BigInteger` — this - a

testBit | () | method |

`public function testBit(n:int):Boolean`

Parameters

| `n:int`

Returns

| `Boolean` — true iff nth bit is set

toArray | () | method |

`public function toArray(array:ByteArray):uint`

Parameters

| `array:ByteArray`

Returns

| `uint`

toByteArray | () | method |

`public function toByteArray():ByteArray`

Returns

| `ByteArray` — a byte array.

toRadix | () | method |

`protected function toRadix(b:uint = 10):String`

Parameters

| `b:uint` (default = `10`)`` — radix to use

Returns

| `String` — a string representing the integer converted to the radix.

toString | () | method |

`public function toString(radix:Number = 16):String`

Parameters

| `radix:Number` (default = `16`)``

Returns

| `String`

valueOf | () | method |

`public function valueOf():Number`

best-effort attempt to fit into a Number. precision can be lost if it just can't fit.

Returns

| `Number`

xor | () | method |

`public function xor(a:BigInteger):BigInteger`

Parameters

| `a:BigInteger`

Returns

| `BigInteger`

Constant Detail

BI_FP | Constant

`public static const BI_FP:int = 52`

DB | Constant |

`public static const DB:int = 30`

DM | Constant |

`public static const DM:int`

DV | Constant |

`public static const DV:int`

F1 | Constant |

`public static const F1:int = 22.0`

F2 | Constant |

`public static const F2:int = 8.0`

FV | Constant |

`public static const FV:Number`

lowprimes | Constant |

`public static const lowprimes:Array`

lplim | Constant |

`public static const lplim:int`

ONE | Constant |

`public static const ONE:BigInteger`

ZERO | Constant |

`public static const ZERO:BigInteger`

Mon May 20 2013, 09:16 PM +02:00