In an Opportunistic network, as data gets transferred from node to node, with the existence of malicious nodes in the network, it is possible that the data gets modified. To make sure that data remains in its original format, we propose a technique that allows nodes to authenticate packets as they receive them by constructing hash trees, also referred to as Merkle trees. Merkle trees are used to check and authenticate all the packets. As a result of this, direct trust is formed. Direct trust is updated based on the authenticity of the packets and the encounter rate with the node. As nodes come into contact with each other during the packet transmission period, they share feedback on how much they trust other nodes. This feedback, in addition to the formed direct trust with a node is used to derive a reputation value. The reputation value allows nodes to make the correct packet transmission decisions when meeting with nodes. Using an OppNet simulator that embeds OppNet protocols, we have tested the proposed reputation-based system. The results show the effectiveness of the reputation system as malicious nodes and modified packets are detected. As a result, the performance of the network improves, and with time, the packet modification rates decrease as malicious nodes are caught.