Traditional encryption and decryption algorithms have high performance overheads in cloud computing environments, and it is difficult to truly balance security and operational efficiency. This paper takes optimizing data encryption and decryption performance and strengthening data information security as the research objectives. After completing the definition of security space text similarity connection and related issues, the cloud computing system model is proposed. Then, combined with the cloud computing environment, the lattice core encryption and decryption algorithm consisting of key generation algorithm, core encryption algorithm and core decryption algorithm is designed. The algorithm ensures that users can perform complex and correct encryption and decryption calculations under limited resources by using fog nodes to bear most of the computational overhead for users. After combining the lattice core encryption and decryption algorithm with the cloud computing model to obtain the data encryption algorithm, a security model is set up to ensure the security of private data such as data information, query information, and result information. The data encryption algorithm in this paper takes only 3.75s and 4.13s to encrypt and decrypt compared to similar algorithms, which is the most efficient encryption and decryption.