如何在没有Stegano模块的情况下将txt文件隐藏到图片中?

问题描述 投票:0回答:1

我想将.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的初学者,很抱歉

python image file security steganography
1个回答
0
投票

只需将file替换为open。另外,您可以使用with,因此您无需在结尾处调用close

with open('makan.png', 'wb') as out:
    out.write(open('sudah.png', 'rb').read())
    out.write(open('cipher.txt', 'rb').read())
© www.soinside.com 2019 - 2024. All rights reserved.