CalculateHashConstant

Calculate the constant for the secondary / supplemental hash function, so that the hash function mixes the input bits as much as possible.

Methods
static long calcMultiplicativeInverse(long a)
Calculate the multiplicative inverse of a value (int).
static long calcMultiplicativeInverse(long a)
Calculate the multiplicative inverse of a value (int).
Parameters:
a - the value
Returns:
the multiplicative inverse
static long calcMultiplicativeInverseLong(long a)
Calculate the multiplicative inverse of a value (long).
static long calcMultiplicativeInverseLong(long a)
Calculate the multiplicative inverse of a value (long).
Parameters:
a - the value
Returns:
the multiplicative inverse
static void main(String... args)
Run just this test.
static void main(String... args) throws Exception
Run just this test.
Parameters:
args - ignored
int getAvalanche(CalculateHashConstant h, int value)
Calculate the number of bits that change if a single bit is changed multiplied by 1000 (expected: 16000 +/- 5%).
int getAvalanche(CalculateHashConstant h, int value)
Calculate the number of bits that change if a single bit is changed multiplied by 1000 (expected: 16000 +/- 5%).
Parameters:
h - the hash object
value - the base value
Returns:
the number of bit changes multiplied by 1000
long getCollisionCount()
long getCollisionCount()
int[] getDependencies(CalculateHashConstant h, int[] values)
Calculate how much the bit changes (output bits that change if an input bit is changed) are independent of each other.
int[] getDependencies(CalculateHashConstant h, int[] values)
Calculate how much the bit changes (output bits that change if an input bit is changed) are independent of each other.
Parameters:
h - the hash object
values - the values to test with
Returns:
the minimum and maximum number of output bits that are changed in combination with another output bit
int[] getEffect(CalculateHashConstant h, int count, int seed)
Calculate if the all bit changes (that an output bit changes if an input bit is changed) are within a certain range.
int[] getEffect(CalculateHashConstant h, int count, int seed)
Calculate if the all bit changes (that an output bit changes if an input bit is changed) are within a certain range.
Parameters:
h - the hash object
count - the number of values to test
seed - the random seed
Returns:
the minimum and maximum value of all input-to-output bit changes
long getEffectSquare(CalculateHashConstant h, int[] values)
Calculate the sum of the square of the distance to the expected probability that an output bit changes if an input bit is changed.
long getEffectSquare(CalculateHashConstant h, int[] values)
Calculate the sum of the square of the distance to the expected probability that an output bit changes if an input bit is changed. The lower the value, the better.
Parameters:
h - the hash object
values - the values to test with
Returns:
sum(distance^2)
int hash(int x)
The hash method.
int hash(int x)
The hash method.
Parameters:
x - the input
Returns:
the output
void run()
void run()
int secureHash(int x)
Calculate a hash using AES.
int secureHash(int x)
Calculate a hash using AES.
Parameters:
x - the input
Returns:
the output
void storeRandomFile()
Store a random file to be analyzed by the Diehard test.
void storeRandomFile() throws Exception
Store a random file to be analyzed by the Diehard test.