The Internet of Things, also called IoT for short, consists of billions of devices distributed around the world, all of which are connected through the Internet. Data is collected by things and shared with each other. Due to the nature and infrastructure of wireless IoT, they have several vulnerabilities. IoT security refers to the protection methods used to secure Internet-connected or network-based devices. In fact, the security of communication between things has become one of the open issues and challenges due to the existence of various types of attacks in IoT. One of these attacks that can disrupt the normal communication between things and destroy the network's efficiency is the wormhole attack. Thus, in this type of attack, two intruders are located in two different areas of the network and try to exchange confidential information quickly, as a result, they inform things about the fake route and things send the information to the destination from the same fake route. In fact, it is sent to the intruder's things, which leads to the deletion of data by these intruders. This attack alters the data stream and misleads the well. Therefore, to solve this problem, the proposed method of this paper (Sec-IoT) addresses two basic issues to secure communication between things against wormhole attacks in the Internet of Things. Thus, in the first phase of Sec-IoT, it examines the trust of all things in the route discovery process. The purpose of the first phase was to identify intruding nodes and remove them from the process of participating in network operations. And in the second phase, Cluster Head selection is done using TOPSIS algorithm and data transfer between things is done encrypted using Hash-based Cryptography. The goal of the second phase was to guarantee the integrity of the information sent. The simulation results showed that the proposed method is superior to HRCA and HBC methods in terms of throughput (25%, 18%), PDR (24%, 19%) and lost packet (19%, 15%).