python - 如何在没有隐写模块的情况下将 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的初学者我很抱歉
解决方案
只需替换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')
推荐阅读
- .net - 从 EF 6.13 升级到 6.2.0 迁移历史记录中断
- java - 如何检测来电和去电?
- python - Python:绘制时间增量和累积值
- python-3.x - 如何从 Gitlab-CI 中的子 Docker 容器访问 Postgres 服务?如何访问 postgres 服务或 gitlab 共享运行器的 IP 地址?
- python - 在顶点和节点中转换的特殊文本以获取图表的路径
- javascript - 如何在表格列中添加阅读更多或更少按钮
- php - 清除缓存时 Symfony 4 内存泄漏
- angular - 如何在Angular中循环嵌套数组
- android - 如何在 android 9 上以编程方式卸载应用程序?
- java - 如何使用 java 将多对(键、值)发送到 Xadd 命令?