Background: Optical information encryption technology has received extensive attention from researchers in recent years because of its advantages of parallel and high-speed processing capability, as well as the controllability of phase components. Methods: An encryption method for grayscale images with a pair of random phase masks based on gamma distribution in the gyrator domain is proposed. In this scheme, two random distribution phase-images using random parameters according to the definition of the gamma probability distribution function are generated. They are loaded onto spatial light modulators as random phase masks used in the encryption process. The input grayscale image transmitted through the first random phase mask. And then they are encoded by the first gyrator transform. The resulting information is again encrypted by a second gamma distribution random phase mask at the gyrator frequency plane. The final results are encoded by the second gyrator transform. Results: Numerical simulations are presented to confirm the security, validity, and flexibility of the proposed idea. The gyrator transform rotation angle sensitivity test is also simulated. The occlusion and noise attacks analysis establish the scheme's robustness. Conclusions: In gyrator transform-based optical image encryption cipher system, encrypting the input image with different parameters of gamma distribution RPMs will significantly change the statistical distribution of phase in the ciphertext. It means that the phase distribution in the ciphertext will not obey the law of random scattering medium. Therefore, it has potential to resist the attack based on the phase retrieval algorithm. Therefore, the security and flexibility of encryption can be improved by using gamma distribution RPMs.