如何在没有隐写模块的情况下将txt文件隐藏到图片中?
how to hide a txt file into a picture without stegano module?
我想将 .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 的初学者,我很抱歉
只需将 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())
从图像中提取文本:
with open('makan.png', 'rb') as f:
text = f.read().split(b'IEND\xaeB`\x82')[1].decode('utf-8')
我想将 .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 的初学者,我很抱歉
只需将 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())
从图像中提取文本:
with open('makan.png', 'rb') as f:
text = f.read().split(b'IEND\xaeB`\x82')[1].decode('utf-8')