public static int [ ] createHashes ( byte [ ] data , int hashes ) { int [ ] result = new int [ hashes ] ; int k = 0 ; byte salt = 0 ; while ( k < hashes ) { byte [ ] digest ; synchronized ( messageDigest ) { messageDigest . update ( salt ) ; salt ++ ; digest = messageDigest . digest ( data ) ; } for ( int i = 0 ; i < digest . length / 4 && k < hashes ; i ++ ) { int h = 0 ; for ( int j = ( i * 4 ) ; j < ( i * 4 ) + 4 ; j ++ ) { h <<= 8 ; h |= ( ( int ) digest [ j ] ) & 0xFF ; } result [ k ] = h ; k ++ ; } } return result ; }
Generates digests based on the contents of an array of bytes and splits the result into 4 - byte int s and store them in an array . The digest function is called until the required number of int s are produced . For each call to digest a salt is prepended to the data . The salt is increased by 1 for each call .