The application provides a method for hiding information in a data file, which can encode secret information in a data file for transmission, and a receiving end can extract the secret information from the data file, and also can extract a generating parameter from the data file or a file name to further recover carrier data with high quality. In the case of not increasing the information transmission rate, one-eighth or more of a large amount of data can be hidden in the data file, the hiding capacity is fixed, the transmission is secret, the image data PSNR is always greater than 51 dB, can reach 60 dB or even infinity, and is suitable for various data security transmission systems.