Code example for CipherOutputStream

Methods: closewrite

0
			SecretKeySpec scs = new SecretKeySpec(key, "AES");
			Cipher cipher = Cipher.getInstance("AES/CFB/NoPadding", "ZBC");
			IvParameterSpec iv = new IvParameterSpec(initVector);
			cipher.init(Cipher.ENCRYPT_MODE, scs, iv);
			ByteArrayOutputStream baos = new ByteArrayOutputStream(data.length);
			CipherOutputStream out = new CipherOutputStream(baos, cipher);
			out.write(data, 0, data.length);
			out.close();
			baos.close();
			return baos.toByteArray();
		} catch (Exception e) {
			throw new CryptoException(e);
		} 
	} 
 
	/* (non-Javadoc) 
	 * @see zorg.platform.CryptoUtils#calculateSHA256HMAC(byte[], int, int, byte[]) 
	 */ 
	@Override 
	public byte[] calculateSHA256HMAC(byte[] data, int offset, int length,
			byte[] aKey) {