This research paper proposes a new intelligent system for text and image encryption and decryption utilizing the RSA3K algorithm and XOR operation for colored images. It aims to enhance data security and improve image recognition rates by combining discrete cosine transform (DCT) and sparse representation techniques. Results demonstrate that the proposed methods maintain good image quality post-decryption while addressing data security challenges, accuracy, and processing times.