Sensor devices in the Wireless Sensor Network (WSN) are commonly subjected to various forms of attacks, such as flood attacks, eavesdropping attacks, etc. When an attacker compromises a sensor device, the sensor device's data contents become non-confidential and are grabbed by the attacker, putting the entire network at risk. As a result, to prevent key leaks in WSN networks, this paper proposes a Token with Secret and Public Keys Sharing (TSP-KS) algorithm. In the existence of attackers, cryptography is used to provide secure communication. A traditional public-key cryptosystem is appropriate in cryptography since it does not need the sender and receiver to supply the same secret to communicate without risk. However, they frequently rely on complex mathematical calculations, making them far less capable than equivalent symmetric-key cryptosystems. The high cost of encrypting long messages with public-key cryptography could be problematic in a wide range of applications. A hybrid system deals with it using a combination of the two. In WSN, Admin creates a token, a secret key, a public key, and a private key. Here, the token is used for access control in sensor devices and the administrator, the secret and public keys are utilized for packet encryption in sensor devices and the base station, and the private key is utilized for decryption in the administrator. Admin shares token with secret and public key for sensor devices and base station for encryption purposes. As a result, the TSP-KS algorithm was utilized to securely share these token with secret and public keys for sensor devices and base station over a distributed way. Experimental results demonstrate that the TSP-KS algorithm securely shares a token with a secret and public key.