首页 > 解决方案 > 如何在没有隐写模块的情况下将 txt 文件隐藏到图片中?

问题描述

我想将 .txt 文件隐藏到图片中,但我不想使用 Stegano,因为我已经使用它,如果我再次使用 Stegano,它将覆盖数据。所以我想使用类似How do I hide a file inside an image with Python?

我尝试使用这些问题的答案

out=file("makan.png","wb")
out.write(file("sudah.png","rb").read())
out.write(file("cipher.txt","rb").read())
out.close()

但它说文件未定义,谁能解释一下?我是python的初学者我很抱歉

标签: pythonimagefilesecuritysteganography

解决方案


只需替换fileopen. 你也可以使用with,所以你不需要close在最后打电话:

with open('makan.png', 'wb') as out:
    out.write(open('sudah.png', 'rb').read())
    out.write(open('cipher.txt', 'rb').read())

从图像中提取文本:

with open('makan.png', 'rb') as f:
    text = f.read().split(b'IEND\xaeB`\x82')[1].decode('utf-8')

推荐阅读