public EncryptableObject decrypt(Key key) throws Exception{
		String Algrithem;
		if(key instanceof PrivateKey){Algrithem = "RSA";}
		else{Algrithem = "AES";}
		if(encrypted == null) {System.out.println("NULL");return null;}
		Cipher decrypt =  Cipher.getInstance(Algrithem);  
		decrypt.init(Cipher.DECRYPT_MODE, key);  
		ByteArrayInputStream bais = new ByteArrayInputStream(encrypted);
		CipherInputStream cin=new CipherInputStream(bais, decrypt);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
		byte[] buf = new byte[2048];
		int read=0;
		while((read=cin.read(buf))!=-1) {//reading encrypted data
			out.write(buf,0,read);  //writing decrypted data
			out.flush();
		}
		out.close();
		cin.close();
		bais.close();
		return EncryptableObject.fromByteArray(out.toByteArray());
	}