如何使用Python隐藏图像中的文件? [英] How do I hide a file inside an image with Python?

查看:110
本文介绍了如何使用Python隐藏图像中的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道可以通过'/B'开关使用'copy'命令进行批量处理,即:

I know it's possible in Batch using the 'copy' command with the '/B' switch, i.e.:

copy /B imagefile+hiddenfile newfile

我的问题是这个;可以在Python中执行此操作吗?如果可以,怎么办?

My question is this; Is it possible to do this in Python, and if so, how?

这个问题非常相似,答案是可以接受的,但我是仍然很好奇;

This question is very similar, and it's answer is acceptable, but I am still curious;

没有逐步模块,有没有办法做到这一点?

Is there a way to do this without the stepic module?

推荐答案

您不需要这样做.

>>> out = file("out.jpg", "wb")
>>> out.write(file("someimage.jpg", "rb").read())
>>> out.write(file("somehiddenfile.pdf", "rb").read())
>>> out.close()

stepic完全不同,它是将真正的"隐藏数据放入图像中,而您的copy方法(以及上面的代码段)只是将文件追加到图像数据之后.从生成的文件中提取"somehiddenfile.pdf"非常容易,而从真实图像中提取隐写信息则要困难得多.

stepic is something completely different it is for putting "really" hidden data into an image, whereas your copy approach (and also my snippet above) just appends the file after the image's data. It is quite easy to extract the "somehiddenfile.pdf" from the generated file, whereas extracting steganographic information out of a real image is a lot more difficult.

这篇关于如何使用Python隐藏图像中的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆