Abstract: Wireless sensor network is an area where there has been a lot of significant developments. These sensors are hugely utilized in many applications like military applications, home automation, and environment surveillance. An application where confidential data is being transmitted requires to be protected from different types of attacks. Though the nodes are authenticated, they are liable to get compromised. The nodes may get compromised by the adversaries and may leak out confidential information. These sensors are subjected to different types of attacks like wormhole attack, Sybil attack, Denial-of-service attack and sinkhole attack. Depending on the type of application utilized level of security can be implemented. This paper utilizes the mobile agent to distribute secret key utilizing one-time pad algorithm. The encryption key hence varies from one cluster to another. To add additional security, comparison is done between the time of dispatch sent by cluster head and monitor nodes.