Is it safe to hash a packet with a shared secret to prove authenticity?
From what you I described I understand your scheme to be following:
Each message $M$ gets a tag $T$ which is $H(S \mathbin\| M)$ where $H$ can be MD5 or SHA2 and $S$ is a common secret. Both hash functions are vulnerable to a length-extension attack effectively allowing to compute $H(S\mathbin\|M\mathbin\|x)$ from $H(S\mathbin\|M)$ and the length of $M$ so your scheme should not be used for authentication.

A better alternative would be to use a message authentication code (short MAC), which is a group of algorithms specifically crafted for cases similar to yours, including the widespread HMAC which allows to turn even broken hash-algorithms like MD5 into relatively secure MAC's.