Code example for SecureRandom

Methods: getAlgorithm, getProvider

0
    } 
 
    @TestTargetNew( 
        level = TestLevel.PARTIAL_COMPLETE, 
        notes = "", 
        method = "nextBytes", 
        args = {byte[].class} 
    ) 
    public final void testNextBytes() { 
        byte[] b = new byte[5];
        SecureRandom sr = new SecureRandom();
        sr.nextBytes(b);
        for (int i = 0; i < b.length; i++) {
            if (b[i] != (byte)(i + 0xF1)) {
                fail("nextBytes failed");
            } 
        } 
         
        try { 
            sr.nextBytes(null);
            fail("expected exception");