Best code examples for Java 8 CipherInputStream class (javax.crypto.CipherInputStream)

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 CipherInputStream class.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

Java 8 CipherInputStream examples from Open Source projects
This code example shows how to use the following methods: available, close, read
    public void testCheckedInputStream() throws IOException { 
        assertReadsFailWithNullPointerException(new CheckedInputStream(null, new CRC32()));
    } 
 
    public void testCipherInputStream() throws IOException { 
        InputStream in = new CipherInputStream(null, new NullCipher());
        try { 
            in.read();
            fail();
        } catch (NullPointerException expected) {
        } 
 
        assertEquals(0, in.available());
 
        try { 
            in.close();
            fail();
        } catch (NullPointerException expected) {
        } 
    } 
 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: decodeStream
            byte[] iv = new byte[DEFAULT_KEY_LENGTH];
            fis.read(iv);
            Cipher cipher = Cipher.getInstance(ENCRYPT_ALGORYTHM);
            IvParameterSpec ivspec = new IvParameterSpec(iv);
            cipher.init(Cipher.DECRYPT_MODE, getKey(password), ivspec);
            cis = new CipherInputStream(fis, cipher);
        } catch (FileNotFoundException e) {
            Log.e(TAG, e.toString());
        } catch (IOException e) {
            Log.e(TAG, e.toString());
        } catch (NoSuchAlgorithmException e) {
            Log.e(TAG, e.toString());
        } catch (NoSuchPaddingException e) {
            Log.e(TAG, e.toString());
        } catch (InvalidKeyException e) {
            Log.e(TAG, e.toString());
        } catch (InvalidAlgorithmParameterException e) {
            Log.e(TAG, e.toString());
        } 
        if (cis == null) return null;

6
CodeRank
This code example shows how to use the following methods:
SecretKey key = getSecretKey();
			dcipher = Cipher.getInstance(key.getAlgorithm());
            AlgorithmParameterSpec paramSpec = new PBEParameterSpec(salt, getIterationCount());
			dcipher.init(Cipher.DECRYPT_MODE, key, paramSpec);
			CipherInputStream cis = new CipherInputStream(in, dcipher);
			return new EncryptedInputStream(cis, password);
		}  
		catch (Exception e) {
			throw new DeploymentException("Unable to initialise decryption cipherName:" + cipherName, e);
		} 
	}	 
	 
	/** 
	 * The name of the cipher to use such as "PBEWithMD5AndDES". 
	 *  
	 * @param cipherName the name of the cipher to use 
	 */ 
	public void setCipherName(String cipherName) {
		this.cipherName = cipherName;
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods:
cipherAlg = STORE_CIPHER;
            } 
 
            Cipher cipher = this.makePBECipher(cipherAlg, Cipher.DECRYPT_MODE, password, salt, iterationCount);
            CipherInputStream cIn = new CipherInputStream(dIn, cipher);
 
            Digest dig = new SHA1Digest();
            DigestInputStream  dgIn = new DigestInputStream(cIn, dig);
     
            this.loadStore(dgIn);
 
            // Finalise our digest calculation 
            byte[] hash = new byte[dig.getDigestSize()];
            dig.doFinal(hash, 0);
 
            // TODO Should this actually be reading the remainder of the stream? 
            // Read the original digest from the stream 
            byte[] oldHash = new byte[dig.getDigestSize()];
            Streams.readFully(cIn, oldHash);

5
CodeRank
This code example shows how to use the following methods: read
    /** 
     * @tests javax.crypto.CipherInputStream#read(byte[] b, int off, int len) 
     */ 
    public void testReadBII() throws Exception { 
        // Regression for HARMONY-1080 
        CipherInputStream stream = new CipherInputStream(null, new NullCipher());
        try { 
            stream.read(new byte[1], 1, 0);
            fail("NullPointerException expected");
        } catch (NullPointerException e) {
            // expected 
        } 
    } 
 
    /** 
     * @tests javax.crypto.CipherInputStream#close() 
     */ 
    public void testClose() throws Exception { 
        // Regression for HARMONY-1087 
        try { 
Full Snippet Info
5
CodeRank
Related Java 8 CipherInputStream Questions & Answers: