In this paper, we apply deep learning for optical encryption in complex scattering media. Ciphertexts are optically obtained by using an interferometric setup through complex scattering media. After the recording of ciphertext, a designed machine learning model is trained by usage of ciphertexts and their corresponding plaintexts. Then, security keys consist of the optimized parameters and the well-trained machine learning model. Supposing that proper security keys are used in the decryption process, plaintexts can be recovered in real time. One point to be highlighted is that the decryption process in the proposed method is not a directly reverse process of encryption. Moreover, security keys in the proposed method can be updated during the training when there is information leakage. In addition to the optimized parameters and the well-trained learning model, extra parameters can be applied to enhance the security. Robustness of the proposed method has been investigated by the eavesdropping attacks. In optical experiments, it is verified that the proposed method by using machine learning to implement optical encryption in complex scattering media is valid and robust. It is expected that this research work can contribute to optical cryptography schemes.