图片隐写术介绍

隐写术是将文本或者文件隐藏到图片文件中,从而实现信息的屏蔽. 本文主要介绍关于Python的steganography包以及相关的用法,以及编程中使用说明 安装 pip install steganography 用法 命令行 steganography包安装之后,命令行中会存在一个steganography的可执行脚本. 加密 steganography -e 原始图片 加密后的图片 "加密的文本" 加密 steganography -d 加密后的图片 代码引用 from steganography.steganography import Steganography # hide text to image path = "/tmp/image/input.jpg" output_path = "/tmp/image/output.jpg" text = 'The quick brown fox jumps over the lazy dog.' Steganography.encode(path, output_path, text) # read secret text from image secret_text = Steganography.decode(output_path) 以后都这样尝试了. 后续 在使用过程中,发现如果是windows存进去的中文文本解码之后可能会存在乱码的情况,这个就是编码的问题了,而且存入的内容没有经过加密的内容直接存入还是不安全. 经过以上分析,我决定自己重写一个脚本. 内容如下: #! /usr/local/bin/python # -*- coding:utf-8 -*- import sys from steganography.