According to the problems of the traditional image encryption algorithm, such as cumbersome encryption process, small keyspace, and insufficient security, a color image encryption algorithm based on a four-dimensional hyperchaotic system and using “conversion-scrambling-diffusion” mode is used. The algorithm utilizes improved Chen’s hyperchaotic system. First, according to the color image correlation attribute, the gray code iteration number was calculated, and the gray code inversely transformed the pixel value. Subsequently, the chaotic sequence generated by the hyperchaotic system was used to convert the gray code converted pixel matrix. The global pixel position was scrambled, and then, the scrambled matrix was bit-operated to complete image diffusion. Finally, the ciphertext was obtained through matrix transformation. The algorithm can realize a picture and a key. Good image encryption algorithms should meet the requirements of large keyspace, key sensitivity, effective resistance to violent attacks, entropy attacks, plaintext attacks, and other attacks as well as real-time requirements. The simulation experiments calculate and analyze evaluation indexes, such as key sensitivity, histogram, image information entropy, including one-dimensional entropy and two-dimensional entropy, and adjacent element correlation. The information entropies are more than 7.99, and the keyspace is larger than 1086. The results prove that the encryption algorithm has robust security and antiattack ability.