Code example for CipherInputStream

Methods: markSupported

0
     * markSupported() method testing. Tests that mark is not supported. 
     */ 
    public void testMarkSupported() { 
        byte[] data = new byte[] {-127, -100, -50, -10, -1, 0, 1, 10, 50, 127};
        TestInputStream tis = new TestInputStream(data);
        CipherInputStream cis = new CipherInputStream(tis, new NullCipher());
        assertFalse("The returned by markSupported() method value "
                + "should be false.", cis.markSupported());
    } 
 
    public void test_ConstructorLjava_io_InputStreamLjavax_crypto_Cipher () throws 
    NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException { 
        ByteArrayInputStream bais = new ByteArrayInputStream(new byte[100]);
 
        KeyGenerator kg = KeyGenerator.getInstance("DES");
        kg.init(56, new SecureRandom());
        Key key = kg.generateKey();
 
        Cipher c = Cipher.getInstance("DES/CBC/NoPadding");
        c.init(Cipher.ENCRYPT_MODE, key);