Logo PTI Logo FedCSIS

Proceedings of the 17th Conference on Computer Science and Intelligence Systems

Annals of Computer Science and Information Systems, Volume 30

Encrypting JPEG-compressed images by substituting Huffman code words

DOI: http://dx.doi.org/10.15439/2022F217

Citation: Proceedings of the 17th Conference on Computer Science and Intelligence Systems, M. Ganzha, L. Maciaszek, M. Paprzycki, D. Ślęzak (eds). ACSIS, Vol. 30, pages 545549 ()

Full text

Abstract. This paper presents a method for encrypting JPEG-coded images that preserves both compression ratio and format of a bit stream. Such solutions allow for selectively hiding information: image contents can be encrypted, while in-file metadata remain readable. Our algorithm is a symmetric, polygram substitution cipher, as it replaces Huffman code words and rearranges value bits that describe the main results of the Discrete Cosine Transform (DCT) of a pixel block: the DC coefficient and the first non-zero AC coefficient. Both length and format of a file are preserved, because bits are modified under constraints on their numbers. Such encryption is a kind of post-processing of a compressed bit stream, and thus it can be built on the top of an existing JPEG codec, without accessing its internals. Compared to previous similar solutions, our approach better hides image contours, exchanging AC for DC energy. Our work also reveals some properties of Huffman code tables and bit streams related to the JPEG standard.


  1. P. Li and K.-T. Lo, “Survey on JPEG compatible joint image compression and encryption algorithms,” IET Signal Process., vol. 14, no. 8, pp. 475–488, 2020. http://dx.doi.org/10.1049/iet-spr.2019.0276
  2. A. Massoudi, F. Lefebvre, C. De Vleeschouwer, B. Macq, and J.-J. Quisquater, “Overview on selective encryption of image and video: Challenges and perspectives,” EURASIP J. Inf. Secur., vol. 2008, pp. 5:1–5:18, Jan. 2008. http://dx.doi.org/10.1155/2008/179290
  3. J. He, S. Huang, S. Tang, and J. Huang, “JPEG image encryption with improved format compatibility and file size preservation,” IEEE Trans. Multimedia, vol. 20, no. 10, pp. 2645–2658, 2018. http://dx.doi.org/10.1109/TMM.2018.2817065
  4. S. Auer, A. Bliem, D. Engel, A. Uhl, and A. Unterweger, “Bitstream-based JPEG encryption in real-time,” Int. J. Digital Crime Forensics, vol. 5, no. 3, pp. 1–14, jul 2013. http://dx.doi.org/10.4018/jdcf.2013070101
  5. K. Kurihara, M. Kikuchi, S. Imaizumi, S. Shiota†, and H. Kiya, “An encryption-then-compression system for JPEG/Motion JPEG standard,” IEICE Trans. Fundam. Electron. Commun. Comput. Sci., vol. E98.A, no. 11, pp. 2238–2245, nov 2015. http://dx.doi.org/10.1587/transfun.E98.A.2238
  6. M. Parfieniuk and P. Jankowski, “Encrypting Huffman-encoded data by substituting pairs of code words without changing the bit count of a pair,” in Proc. 3rd Int. Conf. Cryptography Security Syst. (CSS), Lublin, Poland, 22-24 Sep. 2014. http://dx.doi.org/10.1007/978-3-662-44893-9_2 pp. 12–22.
  7. M. S. Kankanhalli and T. T. Guan, “Compressed-domain scrambler/descrambler for digital video,” IEEE Trans. Consum. Electron., vol. 48, no. 2, pp. 356–365, May 2002. http://dx.doi.org/10.1109/TCE.2002.1010142
  8. C.-P. Wu and C.-C. J. Kuo, “Fast encryption methods for audiovisual data confidentiality,” in Multimedia Syst. Appl. III, ser. Proc. SPIE, vol. 4209, Boston, MA, Nov. 2000. http://dx.doi.org/10.1117/12.420829 pp. 284–295.
  9. S. Li, On the Performance of Secret Entropy Coding: A Perspective Beyond Security. Berlin, Heidelberg: Springer, 2012, pp. 389–401.
  10. W. Li and Y. Yuan, “A leak and its remedy in JPEG image encryption,” Int. J. Computer Mathematics, vol. 84, no. 9, pp. 1367 – 1378, Sep. 2007. http://dx.doi.org/10.1080/00207160701294376
  11. K. Yi and K. Kim, “Encryption method of compressed images with JPEG compliance by shuffling information both in spatial and frequency domains,” in Advanced Multimedia and Ubiquitous Engineering, J. J. Park, H. Jin, Y.-S. Jeong, and M. K. Khan, Eds. Singapore: Springer, 2016. http://dx.doi.org/10.1007/978-981-10-1536-6_86 pp. 661–667.
  12. S. Li and Y. Zhang, “Quantized DCT coefficient category address encryption for JPEG image,” KSII Trans. Internet Inf. Syst., vol. 10, no. 4, pp. 1790–1806, Apr. 2016. http://dx.doi.org/10.3837/tiis.2016.04.018
  13. Y. Mao and M. Wu, “A joint signal processing and cryptographic approach to multimedia encryption,” IEEE Trans. Image Process., vol. 15, no. 7, pp. 2061–2075, Jul. 2006. http://dx.doi.org/10.1109/TIP.2006.873426
  14. S. Lian, J. Sun, and Z. Wang, “A novel image encryption scheme based on JPEG encoding,” in Proc. 8th Int. Conf. Inf. Vis. (IV), London, UK, 16 Jul. 2004. http://dx.doi.org/10.1109/IV.2004.1320147 pp. 217–220.
  15. X. Niu, C. Zhou, J. Ding, and B. Yang, “JPEG encryption with file size preservation,” in Proc. Int. Conf. Intell. Inf. Hiding Multimedia Signal Process. (IIHMSP), Harbin, China, 15-17 Aug. 2008. http://dx.doi.org/10.1109/IIH-MSP.2008.207 pp. 308–311.
  16. B. Yang, C.-Q. Zhou, C. Busch, and X.-M. Niu, “Transparent and perceptually enhanced JPEG image encryption,” in Proc. 16th Int. Conf. Digital Signal Process., Santorini, Greece, 5-7 Jul. 2009. http://dx.doi.org/10.1109/ICDSP.2009.5201075 pp. 1–6.