These days key establishing of two devices in a network places an important role, and the generation of the key is used
for public key-based algorithms. Using this algorithm generates a secret key for two devices in the network so that we can
randomly generate private keys by performing these processes. In the Ad hoc networks, the essential operation of routing is from
the source node to the destination node; by randomly generating this process, we can improve the routing efficiency. In this
paper, we implement the random routing of secure transmission protocol for generating routing and provide the privacy for
transferred messages among the nodes by using the GPSR protocol. Before moving the news, the server will randomly generate
the routing path for the S-node and D-node. These transferring messages or data are encrypted in the s-node, and cipher is sent
to the d-node, then the d-node will retrieve the cipher format data and perform the decryption process and gathers the original
data or message.