Packet integrity or modification attacks commonly happen in Opportunistic Networks (OppNets). In this paper, we propose a technique that uses Merkle trees to protect the integrity of the packets transferred in a network. When adopting the technique in an OppNet, nodes will be able to verify that data transferred from node to node is received unchanged and in its original state. Using a solid trust and reputation system, nodes are able to inform and be informed of legitimate and malicious nodes in the network. The technique has been implemented using an OppNet protocol, and the results reflect the effectiveness of the technique. As modified packets are detected and their transmission is stopped, over time, the packet modification rate drops, thus improving the performance of the network.