The Cloud computing is a repository that stores massive amounts of data that is accessible online. There are many security and data privacy concerns threatening cloud computing services, especially through key sharing. So, there is an important need to improve security algorithms. An electrocardiogram (ECG) measures heart performance and detects arrhythmias. Nowadays, they are used for identification because they vary from one person to another. Therefore, securing an ECG signal is important. Homomorphic encryption (HE) is a security solution that processes encrypted data without decryption. HE supplies the same raw data results. In this paper, to enhance security and maintain data privacy while getting rid of sharing key restrictions, a new fully homomorphic encryption algorithm with an advanced encryption standard (FHEAES) is proposed to encode the ECG signals. This is accomplished by proposing the evaluation process to be appended to an AES algorithm as an additional security layer, which performs a variety of mathematical operations homomorphically on the encrypted data without decrypting it, instead of the original data. The evaluation process is proposed to be a linear polynomial function with variable values to enhance security. A Pan and Tompkins algorithm is used to process ECG signals. Then, the FHEAES algorithm was used for encoding the ECG signal. At last, ECG signals were classified for further diagnosis. According to the findings, FHEAES will take 1.078950 × 1033 years to break or hack. This is due to the using of the proposed three encryption keys to make it harder to break. Also, the FHEAES algorithm has 95.8% accuracy in classification and 100% accuracy in decryption (recovering the original signal). When compared to other algorithms, it is nearly 6 times and 3 times faster during encryption and decryption, respectively. This is because it is proposed to be based on computationally lightweight matrix operations, making it perfect to address the noise that arises from any FHE scheme. Thus, FHEAES provides superior security and privacy while computing and is solid against attacks.