Encoding and decoding method and apparatus based on jpeg file format in the mobile device

The present invention provides a method and apparatus for encoding and decoding based on JPEG file format, the encoding method comprises a mobile device: The privacy code tables for encoding the raw image data to obtain compressed image data of the original; unique to the mobile device encrypted identification to obtain the signature data of the mobile device; generate encoded image data, the encoded image data comprises compressed data and the signature data of the mobile device, wherein the privacy code table is stored in the mobile device. The method without increasing overhead, while able to effectively prevent the illegal distribution and browse files, protects the user's privacy.