public final void testNextBytesbyteArray02 ( ) { byte [ ] myBytes ; byte [ ] myBytes1 ; byte [ ] myBytes2 ; for ( int i = 1 ; i < LENGTH ; i += INCR ) { myBytes = new byte [ i ] ; for ( int j = 1 ; j < i ; j ++ ) { myBytes [ j ] = ( byte ) ( j & 0xFF ) ; } sr . setSeed ( myBytes ) ; sr2 . setSeed ( myBytes ) ; for ( int k = 1 ; k < LENGTH ; k += INCR ) { myBytes1 = new byte [ k ] ; myBytes2 = new byte [ k ] ; sr . nextBytes ( myBytes1 ) ; sr2 . nextBytes ( myBytes2 ) ; for ( int l = 0 ; l < k ; l ++ ) { assertFalse ( "unexpected: myBytes1[l] != myBytes2[l] :: l==" + l + " k=" + k + " i=" + i + " myBytes1[l]=" + myBytes1 [ l ] + " myBytes2[l]=" + myBytes2 [ l ] , myBytes1 [ l ] != myBytes2 [ l ] ) ; } } } for ( int n = 1 ; n < LENGTH ; n += INCR ) { int n1 = 10 ; int n2 = 20 ; int n3 = 100 ; byte [ ] [ ] bytes1 = new byte [ 10 ] [ n1 ] ; byte [ ] [ ] bytes2 = new byte [ 5 ] [ n2 ] ; for ( int k = 0 ; k < bytes1 . length ; k ++ ) { sr . nextBytes ( bytes1 [ k ] ) ; } for ( int k = 0 ; k < bytes2 . length ; k ++ ) { sr2 . nextBytes ( bytes2 [ k ] ) ; } for ( int k = 0 ; k < n3 ; k ++ ) { int i1 = k / n1 ; int i2 = k % n1 ; int i3 = k / n2 ; int i4 = k % n2 ; assertTrue ( "non-equality: i1=" + i1 + " i2=" + i2 + " i3=" + i3 + " i4=" + i4 , bytes1 [ i1 ] [ i2 ] == bytes2 [ i3 ] [ i4 ] ) ; } } }
test against the `` void nextBytes ( byte [ ] ) '' method ; it checks out that different SecureRandom objects being supplied with the same seed return the same sequencies of bytes as results of their `` nextBytes ( byte [ ] ) '' methods