In recent years, applications for wireless sensor networks (WSNs) have tended to transmit data hop by hop, from sensor nodes through the cluster nodes to the base station. As a result, users must collect data from the base station. In this paper, we consider two different applications: hop by hop transmission of data from cluster nodes to the base station and the mobile users can directly get access to the cluster nodes' data via mobile devices. Due to the hardware limitations of WSNs, we use some low-cost operations, such as symmetric cryptographic algorithms and hash function to implement a dynamic key management. The session key can be updated to prevent some threats of the attack from each communication. With these methods, the data gathered in wireless sensor networks can communicate more securely and intelligently.