Code example for SecureRandom

Methods: nextBytes

0
        if (param instanceof KeyParameter && ivSize != 0)
        { 
            iv = new byte[ivSize];
            random.nextBytes(iv);
            param = new ParametersWithIV(param, iv);
        } 
 
        switch (opmode)
        { 
        case Cipher.WRAP_MODE:
            wrapEngine.init(true, param);
            break; 
        case Cipher.UNWRAP_MODE:
            wrapEngine.init(false, param);
            break; 
        case Cipher.ENCRYPT_MODE:
        case Cipher.DECRYPT_MODE:
            throw new IllegalArgumentException("engine only valid for wrapping");
        default: 
            System.out.println("eeek!");
        }