In this paper, we experimentally demonstrate for the first time to our knowledge that optical encryption based on diffractive imaging is vulnerable to the attacks using learning methods. Using machine learning attack, an opponent is capable to retrieve unknown plaintexts from the given ciphertexts. The proposed method adopts end-to-end learning to extract a superior mapping relationship between the ciphertexts and the plaintexts. Without a direct retrieval or estimate of optical encryption keys, an unauthorised user can extract unknown plaintexts from the given ciphertexts by using the trained learning models. Simulations and optical experimental results demonstrate that the proposed learning method is feasible and effective to analyze the vulnerability of optical encryption schemes. The universality of the trained learning model is also illustrated, and it is verified that the machine learning model trained by using a database is robust to be used for attacking different databases. Compared with conventional cryptanalytic methods, the proposed machine learning attacks can retrieve unknown plaintexts from the given ciphertexts using the trained learning models without a direct usage of various different optical encryption keys, which provides a different strategy for the cryptanalysis of optical encryption systems. @ Elsevier, 2019.