Recently, 5G networks have gradually surrounded our living environments to color our everyday lives and make our daily activities more convenient than before. However, in 5G networks, packet P transmitted from local UPFA of a 5G network, e.g., 5G-A, to UPFB in P’s destination 5G network, e.g., 5G-B, is not secure, even not encrypted, particularly via the Internet, A ≠ B. This conducts a risk of data leakage along the connection established between UPFA and UPFB. To solve this problem, in this study, we propose an architecture that encrypts/decrypts P to prevent it from being attacked. P is encrypted by an edge computer, e.g., ECA in 5G-A before it is sent to its destination, and decrypted by another edge computer, e.g., ECB in 5G-B. In this paper, the scenario includes data transmission between two users or among n-party users, n > 2. For the former, the cryptography systems used are symmetric and asymmetric encryption/decryption approaches. For the n-party scheme, we adopt Initial Key Agreement (IKA) mechanism which employs Upflow and Downflow processes to establish a secret key for all participating ECs. Besides, message authentication code, and time stamp are also utilized to enhance the security level of data transmission. Our analyses show that this proposed approach can effectively avoid some types of attacks.