Java 8 NullCipher - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 NullCipher class.

This code example shows how to use the following methods:
    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) {
        } 
    } 
5
CodeRank
This code example shows how to use the following methods:
    /** 
     * @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 { 
4
CodeRank
This code example shows how to use the following methods:
                bos.toByteArray()));
 
        SealedObject so_des = (SealedObject) ois.readObject();
        assertEquals("The secret content of deserialized object "
                + "should be equal to the secret content of initial object", 
                secret, so_des.getObject(new NullCipher()));
        assertEquals("The value returned by getAlgorithm() method of "
                + "deserialized object should be equal to the value returned " 
                + "by getAlgorithm() method of initial object", so
                .getAlgorithm(), so_des.getAlgorithm());
    } 
 
    /** 
     * SealedObject(Serializable object, Cipher c) method testing. Tests if the 
     * NullPointerException is thrown in the case of null cipher. 
     */ 
    public void testSealedObject1() throws Exception { 
        String secret = "secret string";
        try { 
            new SealedObject(secret, null);
4
CodeRank
This code example shows how to use the following methods:
 
    private Cipher c;
 
    protected void setUp() throws Exception { 
        super.setUp(); 
        c = new NullCipher();
    } 
 
    public void testGetAlgorithm() { 
        c.getAlgorithm();
    } 
 
    public void testGetBlockSize() { 
        assertEquals("Incorrect BlockSize", 1, c.getBlockSize());
    } 
 
    public void testGetOutputSize() { 
        assertEquals("Incorrect OutputSize", 111, c.getOutputSize(111));
    } 
 
4
CodeRank
This code example shows how to use the following methods:
                bos.toByteArray()));
 
        SealedObject so_des = (SealedObject) ois.readObject();
        assertEquals("The secret content of deserialized object "
                + "should be equal to the secret content of initial object", 
                secret, so_des.getObject(new NullCipher()));
        assertEquals("The value returned by getAlgorithm() method of "
                + "deserialized object should be equal to the value returned " 
                + "by getAlgorithm() method of initial object", so
                .getAlgorithm(), so_des.getAlgorithm());
    } 
 
    /** 
     * SealedObject(Serializable object, Cipher c) method testing. Tests if the 
     * NullPointerException is thrown in the case of null cipher. 
     */ 
    public void testSealedObject1() throws Exception { 
        String secret = "secret string";
        try { 
            new SealedObject(secret, null);
4
CodeRank
This code example shows how to use the following methods:
	 * @param os 
	 *            the output stream to write the data to. 
	 * @throws IOException  
	 */ 
	protected CipherOutputStreamToSE(OutputStream os) throws IOException {
		this(os, new NullCipher());
	} 
 
	/*** 
	 * Writes the single byte to this cipher output stream. 
	 * 
	 * @param b 
	 *            the byte to write. 
	 * @throws IOException 
	 *             if an error occurs. 
	 */ 
	@Override 
	public void write(int b) throws IOException {
		Log.e(TAG,"UPDATE 1 byte");
		startTime = System.currentTimeMillis();
4
CodeRank
This code example shows how to use the following methods:
	 */ 
	protected CipherInputStream(InputStream is)
	{ 
		super(is);
		input = is;
		cipher = new NullCipher();
	} 
 
	/** 
	 * Reads the next byte of data from this input stream. The value byte is returned as an <code>int</code> in the range <code>0</code> to <code>255</code>. If no byte is available because the 
	 * end of the stream has been reached, the value <code>-1</code> is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown. 
	 * <p> 
	 *  
	 * @return the next byte of data, or <code>-1</code> if the end of the stream is reached. 
	 * @exception IOException 
	 *                if an I/O error occurs. 
	 * @since JCE1.2 
	 */ 
	public int read() throws IOException 
	{ 
4
CodeRank
This code example shows how to use the following methods:doFinal, getBlockSize, getExemptionMechanism, getIV, getOutputSize
    static { 
        new SecureRandom().nextBytes(BYTES);
    } 
 
    public static void main(String[] args) throws Exception {
        NullCipher nc = new NullCipher();
        // testing init(...) 
        nc.init(Cipher.ENCRYPT_MODE, (Certificate) null);
        nc.init(Cipher.ENCRYPT_MODE, (Certificate) null, (SecureRandom) null);
        nc.init(Cipher.ENCRYPT_MODE, (Key) null);
        nc.init(Cipher.ENCRYPT_MODE, (Key) null, (AlgorithmParameters) null);
        nc.init(Cipher.ENCRYPT_MODE, (Key) null, (AlgorithmParameterSpec) null);
        nc.init(Cipher.ENCRYPT_MODE, (Key) null, (AlgorithmParameterSpec) null,
            (SecureRandom) null);
        nc.init(Cipher.ENCRYPT_MODE, (Key) null, (AlgorithmParameters) null,
            (SecureRandom) null);
        nc.init(Cipher.ENCRYPT_MODE, (Key) null, (SecureRandom) null);
        // testing getBlockSize() 
        if (nc.getBlockSize() != 1) {
            throw new Exception("Error with getBlockSize()");

-3
CodeRank
This code example shows how to use the following methods:doFinal, getBlockSize, getExemptionMechanism, getIV, getOutputSize
    static { 
        new SecureRandom().nextBytes(BYTES);
    } 
 
    public static void main(String[] args) throws Exception {
        NullCipher nc = new NullCipher();
        // testing init(...) 
        nc.init(Cipher.ENCRYPT_MODE, (Certificate) null);
        nc.init(Cipher.ENCRYPT_MODE, (Certificate) null, (SecureRandom) null);
        nc.init(Cipher.ENCRYPT_MODE, (Key) null);
        nc.init(Cipher.ENCRYPT_MODE, (Key) null, (AlgorithmParameters) null);
        nc.init(Cipher.ENCRYPT_MODE, (Key) null, (AlgorithmParameterSpec) null);
        nc.init(Cipher.ENCRYPT_MODE, (Key) null, (AlgorithmParameterSpec) null,
            (SecureRandom) null);
        nc.init(Cipher.ENCRYPT_MODE, (Key) null, (AlgorithmParameters) null,
            (SecureRandom) null);
        nc.init(Cipher.ENCRYPT_MODE, (Key) null, (SecureRandom) null);
        // testing getBlockSize() 
        if (nc.getBlockSize() != 1) {
            throw new Exception("Error with getBlockSize()");

-2
CodeRank
See Code Examples for Java 8 NullCipher Methods: