Currently, visual data security plays a significant role in various fields, especially in medical imaging. Addressing the challenges associated with limited key space and vulnerability to different types of attacks within current encryption schemes, this work proposes an optimal compression-encryption scheme for large medical images that incorporates elements of Archimedes' optimization algorithm, discrete orthogonal Hahn moments, chaotic systems, and DNA coding. The primary aim of this study is to develop an optimal and exceptionally resilient compression-encryption scheme capable of countering various attack types effectively. This approach is structured into three principal phases: a compression phase harnessing the efficiencies of Hahn's discrete orthogonal moments (HMs) in signal and image representation, coupled with the Archimedes optimization algorithm (AO) to ensure optimal tuning of polynomial parameters (a, b) for superior image reconstruction quality. The encryption phase is performed on the compressed image, using hyperchaotic memristive 4-D (HCM-4D), adapted logistics map (ALM) and DNA coding. Initially, the adapted logistics map is responsible for generating random sequences linked to the compressed image. Subsequently, chaotic sequences originating from the hyperchaotic 4-D memristive system govern both random sequences and DNA processes. The optimization phase, facilitated by the AO algorithm, focuses on minimizing the value of the objective function (correlation) on the compressed and encrypted images. Ultimately, the image with the lowest correlation value is designated as the optimal compressed-encrypted representation.The simulation results clearly illustrate the resilience of the AO algorithm when juxtaposed with other optimization algorithms, especially with respect to convergence speed and computational efficiency. On the other hand, the proposed compression approach demonstrated exceptional efficiency in compressing medical images, offering us the possibility to achieve impressive compression ratio (CR) as well as exceptional quality in decompressed images, evident thanks to high PSNR values. In addition, security analyze demonstrate that the proposed compression-encryption benefits from a larger key space and superior resistance against different types of attacks. Furthermore, our approach was subjected to a comparative analysis alongside various encryption method. These comparisons demonstrate that our encryption algorithm surpasses others in terms of both security and effectiveness.