{"id":17968366,"url":"https://github.com/guofei9987/hideinfo","last_synced_at":"2025-04-05T03:10:19.444Z","repository":{"id":191765298,"uuid":"685056356","full_name":"guofei9987/HideInfo","owner":"guofei9987","description":"一些小而美的信息隐藏技术：幻影坦克、藏物于音等","archived":false,"fork":false,"pushed_at":"2024-06-03T14:07:42.000Z","size":10242,"stargazers_count":487,"open_issues_count":0,"forks_count":45,"subscribers_count":5,"default_branch":"main","last_synced_at":"2024-10-29T16:01:06.160Z","etag":null,"topics":["python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/guofei9987.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-30T12:27:24.000Z","updated_at":"2024-10-29T03:40:11.000Z","dependencies_parsed_at":null,"dependency_job_id":"e5cf0493-f830-46eb-bc7c-09bda374e566","html_url":"https://github.com/guofei9987/HideInfo","commit_stats":{"total_commits":50,"total_committers":2,"mean_commits":25.0,"dds":0.14,"last_synced_commit":"77580333833e5f396bccaa65b15bb807a3dce49c"},"previous_names":["guofei9987/cloakware","guofei9987/hideinfo"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guofei9987%2FHideInfo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guofei9987%2FHideInfo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guofei9987%2FHideInfo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guofei9987%2FHideInfo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/guofei9987","download_url":"https://codeload.github.com/guofei9987/HideInfo/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247280272,"owners_count":20912967,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["python"],"created_at":"2024-10-29T14:21:08.321Z","updated_at":"2025-04-05T03:10:19.412Z","avatar_url":"https://github.com/guofei9987.png","language":"Python","readme":"# HideInfo\n\nInfo Hiding Library  \n一些小而美的信息隐藏方法  \n\n\n\n[![PyPI](https://img.shields.io/pypi/v/HideInfo)](https://pypi.org/project/HideInfo/)\n[![License](https://img.shields.io/pypi/l/HideInfo.svg)](https://github.com/guofei9987/HideInfo/blob/master/LICENSE)\n![Python](https://img.shields.io/badge/python-\u003e=3.5-green.svg)\n![Platform](https://img.shields.io/badge/platform-windows%20|%20linux%20|%20macos-green.svg)\n[![stars](https://img.shields.io/github/stars/guofei9987/HideInfo.svg?style=social)](https://github.com/guofei9987/HideInfo/)\n[![fork](https://img.shields.io/github/forks/guofei9987/HideInfo?style=social)](https://github.com/guofei9987/HideInfo/fork)\n[![Downloads](https://pepy.tech/badge/HideInfo)](https://pepy.tech/project/HideInfo)\n\n\n\n\n| 算法                                                                                         | 说明                |\n|--------------------------------------------------------------------------------------------|-------------------|\n| [幻影坦克](https://github.com/guofei9987/HideInfo/blob/main/example/example_mirage_tank.py)    | 使图片在不同的背景下显示不同的图片 |\n| [化物为图](https://github.com/guofei9987/HideInfo/blob/main/example/example_hide_as_img.py)    | 把数据以图片形式存放        |\n| [藏物于图](https://github.com/guofei9987/HideInfo/blob/main/example/example_hide_in_img.py)    | 把数据藏在一个图片中        |\n| [图片隐水印](https://github.com/guofei9987/HideInfo/blob/main/example/example_img_watermark.py) | 图片空域上的隐水印         |\n| [图种](https://github.com/guofei9987/HideInfo/blob/main/example/example_img_seed.py)         | 把图片和文件黏在一起，并存为图片  |\n| [EXIF](https://github.com/guofei9987/HideInfo/blob/main/example/example_img_exif.py)       | 把一段信息放到图片的EXIF中   |\n| [化物为音](https://github.com/guofei9987/HideInfo/blob/main/example/example_hide_as_music.py)  | 把数据以音频的形式存放       |\n| [藏物于音](https://github.com/guofei9987/HideInfo/blob/main/example/example_hide_in_music.py)  | 把数据隐藏在一个音频中       |\n| [回声水印](https://github.com/guofei9987/HideInfo/blob/main/example/example_hide_in_music.py)  | 以回声的形式，把二进制嵌入到音频中 |\n| [化物为文](https://github.com/guofei9987/HideInfo/blob/main/example/example_hide_as_txt.py)    | 把数据以文本文件的形式存放     |\n| [藏物于文](https://github.com/guofei9987/HideInfo/blob/main/example/example_hide_in_txt.py)    | 把数据隐藏在一段文本中       |\n\n\n\n\n安装\n```\npip install HideInfo\n```\n\n\n## 幻影坦克\n\n功能：把两个图片合并，使其在黑色背景下显示图片A，在白色背景下显示图片B\n\n说明\n- 已支持彩色图片\n- 一般情况下，手机/浏览器的预览和点击大图分别使黑色背景和白色背景，因此有\"预览和点击是两张不通的图\"的效果\n- 短视频：[B站](https://www.bilibili.com/video/BV1DF41117c7/)\n- 例子：[example/example_mirage_tank.py](example/example_mirage_tank.py)\n\n```python\nfrom hide_info import mirage_tank\n\nmirage_tank.mirage_tank('图片.png', 'img2.jpeg', '幻影坦克.png')\n```\n\n## hide_as_img:化物为图\n\n功能：把文件/文本/bytes 类数据，转换为图片  \n原理：图片 1 个像素的 1 个通道可以存放 0-255 的数字，也就是一个字节。因此可以用来存放数据。\n使用场景：\n    - 信息隐藏、隐蔽传输\n    - 在只能发送图片的场景下（例如社交软件），发送任意信息\n\n说明\n- RGB 3个通道都用来存放数据\n- 使用前4个字节记录数据的大小，因此要求总的数据量小于 4G\n- 可以存放文件、文本、bytes 类数据，把它转化为一张图片\n- 代码：[example_hide_as_img.py](example/example_hide_as_img.py)\n\n```python\nfrom hide_info import hide_as_img\n\n# 文件转为图片并存下来\nhide_as_img.file_encode(filename='要隐藏的文件.zip', img_filename='化物为图.png')\n# 把图片再转回文件\nhide_as_img.file_decode(filename='化物为图-解出来的文件.zip', img_filename='化物为图.png')\n```\n\n## hide_in_img：藏物于图\n\n功能：文件/文本/bytes 类数据，藏进一个 PNG 图片中，并且用肉眼无法看出区别\n原理：（LSB算法）根据信息的二进制，改变像素数据的最低位，肉眼是无法察觉这种改变\n使用场景：\n    - 信息隐藏、隐蔽传输\n    - 在只能发送图片的场景下（例如某社交软件），发送任意信息\n    - 盲水印、图片溯源、版权保护\n\n\n说明\n- 解原始数据时，无需原图参与，只看最低位\n- 使用前4个字节存放数据的大小\n- 使用位运算，提高一定的性能\n- LSB算法对压缩、转格式等攻击脆弱\n- 例子：[example_hide_in_img.py](example/example_hide_in_img.py)\n\n```python\nfrom hide_info import hide_in_img\n\n# 把文件隐藏到图片中\nhide_in_img.file_encode(filename='要隐藏的文件.zip', img_filename='图片.png', img_filename_new='藏物于图.png')\n# 从图片中提取文件\ntext_encode = hide_in_img.file_decode('藏物于图-解出的文件.zip', img_filename='藏物于图.png')\n```\n\n## img_watermark: 图片空域上的隐水印\n\n说明：\n- 同样使用 LSB 算法。 \n- 水印是一个 **二值图**。\n- 可对抗裁剪攻击\n- 如果图片有大片纯色区域，对这些攻击有一定的鲁棒性：缩放、转格式、截图、裁剪。如果没有大片纯色区域，则不能对抗这些攻击。\n- 例子：[example/example_img_watermark.py](https://github.com/guofei9987/HideInfo/blob/main/example/example_img_watermark.py)\n\n代码 \n```python\nfrom hide_info import img_watermark\n\n# 嵌入隐式水印\nimg_watermark.file_encode(img_filename=\"图片.png\", watermark_filename=\"watermark.png\", img_filename_new=\"图片_打入水印.png\")\n\n# 提取隐式水印\nimg_watermark.file_decode(img_filename=\"图片_打入水印.png\", wm_extract=\"解出的水印.png\")\n```\n\n## img_seed:图种\n\n功能：把图片和文件连接起来，以图片的形式存下来（目前还不完善）\n\n- 例子：[example/example_img_seed.py](example/example_img_seed.py)\n\n## img_exif:把信息隐藏在图片的EXIF中\n\n功能：把信息隐藏在图片的 EXIF 中，从而获得隐蔽信息、传输隐蔽信息的能力\n\n- 例子：[example/example_img_exif.py](example/example_img_exif.py)\n\n## hide_in_music: 藏物于音\n\n功能：把一段信息（文件/文本/bytes），藏进一个音乐文件中\n\n例子：\n- [example_hide_in_music.py](example/example_hide_in_music.py)\n\n```python\nfrom hide_info import hide_in_music\n\n# 把文件隐藏到某个音乐中\nhide_in_music.file_encode(filename='要隐藏的文件.zip', music_filename=\"音乐.wav\", music_filename_new=\"藏物于音.wav\")\n# 从音乐中提取文件\nhide_in_music.file_decode(filename=\"藏物于音-解出的文件.zip\", music_filename=\"藏物于音.wav\")\n```\n\n## hide_as_music：化物为音\n\n功能：把一段信息（文件/文本/bytes），转为声音\n原理：用 16 种音可以表示一个四进制。如果每个音持续 0.05 秒，那么每秒声音可以存放 10 字节\n使用场景：\n    - 信息隐藏、隐蔽传输\n    - 在只能发送图片的场景下（例如某社交软件），发送任意信息\n    \n\n说明\n- 例子：[hide_as_music.py](example/example_hide_as_music.py)\n\n```python\nfrom hide_info import hide_as_music\n\n# 文件转为声音并存下来\nhide_as_music.file_encode(filename='要隐藏的文件2.zip', wav_filename='化物为音.wav')\n# 把声音再转回文件\nhide_as_music.file_decode(filename='化物为音-解出来的文件.zip', wav_filename='化物为音.wav')\n\n```\n\n## echo_watermark: 回声水印\n\n回声水印（Echo Watermarking）是一种音频水印技术，通过在原始音频信号中添加回声来嵌入信息。这种技术利用了人耳的心理声学特性，即人耳对于短时间内的回声延迟是不敏感的，因此可以将信息隐藏在音频信号的回声中而不影响听感。\n\n回声水印的实现通常有两个重要参数：回声延迟和回声幅度。延迟时间决定了回声在原始信号之后多久发生，而幅度则影响回声的强度。通过巧妙地调节这两个参数，可以将数字信息（如比特流）编码到音频信号中。\n\n例如，可以用短的延迟时间表示比特'0'，用长的延迟时间表示比特'1'，或者通过调整回声的幅度来表示不同的数据位。\n\n回声水印技术对于音质的影响相对较小，同时具有较好的鲁棒性，能够在一定程度上抵抗压缩、转换等处理过程。这使得它适用于版权保护、内容认证、隐秘通讯等领域。\n\n```python\nfrom hide_info.echo_watermark import EchoWatermark, get_error_rate\nfrom hide_info import utils\n\nori_file = \"sounds.wav\"  # 载体\nembedded_file = \"sounds_with_watermark.wav\"  # 嵌入水印后的文件名\nwm_str = \"回声水印算法，欢迎 star!\"  # 水印\n\nwm_bits = utils.bytes2bin(wm_str.encode('utf-8'))\nlen_wm_bits = len(wm_bits)\n\n# 嵌入水印\necho_wm = EchoWatermark(pwd=111001)\necho_wm.embed(origin_filename=ori_file, wm_bits=wm_bits, embed_filename=embedded_file)\n\n# 提取水印\necho_wm = EchoWatermark(pwd=111001)\nwm_extract = echo_wm.extract(embed_filename=embedded_file, len_wm_bits=len_wm_bits)\n\nwm_str_extract = utils.bin2bytes(wm_extract).decode('utf-8', errors='replace')\nprint(\"解出水印：\", wm_str_extract)\n# 错误率：\nget_error_rate(wm_extract, wm_bits)\n```\n\n\n## hide_in_text：藏物于文\n\n功能：把一段信息（文件/文本/bytes），藏进一段文本中\n\n说明\n- 实测在苹果设备 Macbook、IOS 上，隐藏前后的文本看不出区别。但是 Windows 和某些安卓系统上，会有空格\n- 例子：[hide_in_txt.py](example/example_hide_in_txt.py)\n\n```python\nfrom hide_info import hide_in_txt\n\n# 把一个文件隐藏在一段已有的文本中\nhide_in_txt.file_encode(filename='要隐藏的文件2.zip', text_filename='一段文本.txt', text_filename_new='藏物于文.txt')\n# 从文本中提取文件\nhide_in_txt.file_decode(filename='藏物于文-解出的文件.zip', text_filename='藏物于文.txt')\n```\n\n## hide_as_txt: 化物为文\n\n功能：把一段信息（文件/文本/bytes），以文本的形式存放下来\n\n说明\n- 使用的是 base85 算法\n- 例子：[hide_as_txt.py](example/example_hide_as_txt.py)\n\n```python\nfrom hide_info import hide_as_txt\n\n# 把一个文件转化为一段文本，并存下走\nhide_as_txt.file_encode(filename='要隐藏的文件.zip', txt_filename='化物为文.txt')\n# 从文本中提取文件\nhide_as_txt.file_decode(filename='化物为文-解出的文件.zip', txt_filename='化物为文.txt')\n```\n\n## 其他算法\n\n缩放藏图：提前计算用近邻法缩放时使用的时哪些像素点，然后把这些像素点变成另一个图。\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguofei9987%2Fhideinfo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fguofei9987%2Fhideinfo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguofei9987%2Fhideinfo/lists"}