Hello,
Im currently writting one client-server application and I got stuck with crypting object that will be send throught network.

Here is my class dedicated to encrypting and decrypting:
Java Code:
public class Security {
	
	public static Object encrypt(Object obj){
		SealedObject so = null;
		try {
			
			Cipher cp = Cipher.getInstance("DES");
			cp.init(Cipher.ENCRYPT_MODE, getKey());
			
			so = new SealedObject(obj, cp);
			
		} catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException e) {
			e.printStackTrace();
		}
		return so;
	}
	
	public static Object decrypt(Object obj){
		Object o = null;
		try {
			
			Cipher cp = Cipher.getInstance("DES");
			cp.init(Cipher.DECRYPT_MODE, getKey());
			
			o = ((SealedObject)obj).getObject(cp);
			
		} catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException | ClassNotFoundException | IllegalBlockSizeException | BadPaddingException | IOException e) {
			e.printStackTrace();
		}
		return o;
	}
	
	private static SecretKey getKey() throws NoSuchAlgorithmException{		
		KeyGenerator kg = KeyGenerator.getInstance("DES");
		kg.init(new SecureRandom("keyValue".getBytes()));
		return kg.generateKey();
	}
}
What my problem is that SealedObject accept Object that implements Serializable and Cipher. As I wanna make these two function universal to all object that I will pass throught network, I need way to work it with Object as global.
I think of rewrite these function as generic, but I don't know how to filter object by Interface they implements.
Any help on these, or maybe there is some better way to achive these?

Thanks,
Bizz