text-blind-watermark


Nametext-blind-watermark JSON
Version 0.3.1 PyPI version JSON
download
home_pagehttps://github.com/guofei9987/text_blind_watermark
SummaryText Blind Watermark in Python
upload_time2024-01-05 06:03:36
maintainer
docs_urlNone
authorGuo Fei
requires_python>=3.5
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage No coveralls.
            # text_blind_watermark

Put message(blind watermark) into a text. so that the message is invisible, and the changes of the text are not perceptible.

[![PyPI](https://img.shields.io/pypi/v/text_blind_watermark)](https://pypi.org/project/text_blind_watermark/)
[![Build Status](https://app.travis-ci.com/guofei9987/text_blind_watermark.svg?branch=main)](https://app.travis-ci.com/guofei9987/text_blind_watermark)
[![codecov](https://codecov.io/gh/guofei9987/text_blind_watermark/branch/main/graph/badge.svg?token=85EAN4IVM6)](https://codecov.io/gh/guofei9987/text_blind_watermark)
[![License](https://img.shields.io/pypi/l/text_blind_watermark.svg)](https://github.com/guofei9987/text_blind_watermark/blob/master/LICENSE)
![Python](https://img.shields.io/badge/python->=3.5-green.svg)
![Platform](https://img.shields.io/badge/platform-windows%20|%20linux%20|%20macos-green.svg)
[![stars](https://img.shields.io/github/stars/guofei9987/text_blind_watermark.svg?style=social)](https://github.com/guofei9987/text_blind_watermark/)
[![fork](https://img.shields.io/github/forks/guofei9987/text_blind_watermark?style=social)](https://github.com/guofei9987/text_blind_watermark/fork)
[![Downloads](https://pepy.tech/badge/text_blind_watermark)](https://pepy.tech/project/text_blind_watermark)


- Video demo:[https://www.bilibili.com/video/BV1m3411s7kT](https://www.bilibili.com/video/BV1m3411s7kT)
- Online demo: [https://www.guofei.site/pictures_for_blog/app/text_watermark/v1.html](https://www.guofei.site/pictures_for_blog/app/text_watermark/v1.html)
- **中文 readme** [README_cn.md](README_cn.md)
- **Source code:** [https://github.com/guofei9987/text_blind_watermark](https://github.com/guofei9987/text_blind_watermark)


Can be used in 
- [x] Wechat
- [x] dingding
- [x] zhihu.com 
- [x] ...

## How to Use

install

```bash
>pip install text_blind_watermark
```

### embed message into text:

```python
from text_blind_watermark import TextBlindWatermark2

password = '20190808'
text = '这句话中有盲水印,你能提取出来吗?'
watermark = 'github.com/guofei9987'

text_blind_wm = TextBlindWatermark2(password=password)

text_with_wm = text_blind_wm.embed(text=text, watermark=watermark)
print(text_with_wm)
```


### extract message from text

```python
text_blind_wm2 = TextBlindWatermark2(password=password)
wm_extract = text_blind_wm2.extract(text_with_wm)
print('提取内容:', wm_extract)
```

>github.com/guofei9987



### `chr_type`

You can choose different type to get better performance.


```python
from text_blind_watermark import TextBlindWatermark2

password = '20190808'
text = '这句话中有盲水印,你能提取出来吗?'
watermark = 'github.com/guofei9987'

text_blind_wm = TextBlindWatermark2(password=password, chr_type=(3, 4))

text_with_wm = text_blind_wm.embed(text=text, watermark=watermark)
print(text_with_wm)

text_blind_wm2 = TextBlindWatermark2(password=password, chr_type=(3, 4))
wm_extract = text_blind_wm2.extract(text_with_wm)
print('提取内容:', wm_extract)
assert watermark == wm_extract
```

## Another algorithm is more robust

### Alice Put her text watermark into a text:

```python
from text_blind_watermark import TextBlindWatermark

watermark = "绝密:两点老地方见!"
text = "这句话中有盲水印,你能提取出来吗?" * 16
password = "20190808"

twm = TextBlindWatermark(password=password)
twm.read_wm(watermark=watermark)
twm.read_text(text=text)
text_embed = twm.embed()

print("打上盲水印之后:")
print(text_embed)
```

Then, you can paste this text to where you need.



### Bob Extract the invisible watermark

```python
from text_blind_watermark import TextBlindWatermark
password = "20190808"

twm_new = TextBlindWatermark(password=password)
wm_extract = twm_new.extract(text_embed)
print("解出的盲水印:")
print(wm_extract)
```

## Related Project

HideInfo:[https://github.com/guofei9987/HideInfo](https://github.com/guofei9987/HideInfo)


| 算法   | 说明                |
|------|-------------------|
| [migrate tank](https://github.com/guofei9987/HideInfo/blob/main/example/example_mirage_tank.py) | 使图片在不同的背景下显示不同的图片 |
| [hide as image](https://github.com/guofei9987/HideInfo/blob/main/example/example_hide_as_img.py) | 把数据以图片形式存放        |
| [hide in image](https://github.com/guofei9987/HideInfo/blob/main/example/example_hide_in_img.py) | 把数据藏在一个图片中          |
| [image seed](https://github.com/guofei9987/HideInfo/blob/main/example/example_img_seed.py)   | 把图片和文件黏在一起,并存为图片  |
| [EXIF](https://github.com/guofei9987/HideInfo/blob/main/example/example_img_exif.py) | 把一段信息放到图片的EXIF中   |
| [hide as music](https://github.com/guofei9987/HideInfo/blob/main/example/example_hide_as_music.py) | 把数据以音频的形式存放       |
| [hide in music](https://github.com/guofei9987/HideInfo/blob/main/example/example_hide_in_music.py) | 把数据隐藏在一个音频中       |
| [hide as text](https://github.com/guofei9987/HideInfo/blob/main/example/example_hide_as_txt.py) | 把数据以文本文件的形式存放 |
| [hide in text](https://github.com/guofei9987/HideInfo/blob/main/example/example_hide_in_txt.py) | 把数据隐藏在一段文本中 |


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/guofei9987/text_blind_watermark",
    "name": "text-blind-watermark",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.5",
    "maintainer_email": "",
    "keywords": "",
    "author": "Guo Fei",
    "author_email": "guofei9987@foxmail.com",
    "download_url": "https://files.pythonhosted.org/packages/79/51/9653e90ba2f937b50b83ddb9cc8e599254b9977c5c98471a855957f04d4a/text_blind_watermark-0.3.1.tar.gz",
    "platform": "linux",
    "description": "# text_blind_watermark\n\nPut message(blind watermark) into a text. so that the message is invisible, and the changes of the text are not perceptible.\n\n[![PyPI](https://img.shields.io/pypi/v/text_blind_watermark)](https://pypi.org/project/text_blind_watermark/)\n[![Build Status](https://app.travis-ci.com/guofei9987/text_blind_watermark.svg?branch=main)](https://app.travis-ci.com/guofei9987/text_blind_watermark)\n[![codecov](https://codecov.io/gh/guofei9987/text_blind_watermark/branch/main/graph/badge.svg?token=85EAN4IVM6)](https://codecov.io/gh/guofei9987/text_blind_watermark)\n[![License](https://img.shields.io/pypi/l/text_blind_watermark.svg)](https://github.com/guofei9987/text_blind_watermark/blob/master/LICENSE)\n![Python](https://img.shields.io/badge/python->=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/text_blind_watermark.svg?style=social)](https://github.com/guofei9987/text_blind_watermark/)\n[![fork](https://img.shields.io/github/forks/guofei9987/text_blind_watermark?style=social)](https://github.com/guofei9987/text_blind_watermark/fork)\n[![Downloads](https://pepy.tech/badge/text_blind_watermark)](https://pepy.tech/project/text_blind_watermark)\n\n\n- Video demo\uff1a[https://www.bilibili.com/video/BV1m3411s7kT](https://www.bilibili.com/video/BV1m3411s7kT)\n- Online demo: [https://www.guofei.site/pictures_for_blog/app/text_watermark/v1.html](https://www.guofei.site/pictures_for_blog/app/text_watermark/v1.html)\n- **\u4e2d\u6587 readme** [README_cn.md](README_cn.md)\n- **Source code:** [https://github.com/guofei9987/text_blind_watermark](https://github.com/guofei9987/text_blind_watermark)\n\n\nCan be used in \n- [x] Wechat\n- [x] dingding\n- [x] zhihu.com \n- [x] ...\n\n## How to Use\n\ninstall\n\n```bash\n>pip install text_blind_watermark\n```\n\n### embed message into text:\n\n```python\nfrom text_blind_watermark import TextBlindWatermark2\n\npassword = '20190808'\ntext = '\u8fd9\u53e5\u8bdd\u4e2d\u6709\u76f2\u6c34\u5370\uff0c\u4f60\u80fd\u63d0\u53d6\u51fa\u6765\u5417\uff1f'\nwatermark = 'github.com/guofei9987'\n\ntext_blind_wm = TextBlindWatermark2(password=password)\n\ntext_with_wm = text_blind_wm.embed(text=text, watermark=watermark)\nprint(text_with_wm)\n```\n\n\n### extract message from text\n\n```python\ntext_blind_wm2 = TextBlindWatermark2(password=password)\nwm_extract = text_blind_wm2.extract(text_with_wm)\nprint('\u63d0\u53d6\u5185\u5bb9\uff1a', wm_extract)\n```\n\n>github.com/guofei9987\n\n\n\n### `chr_type`\n\nYou can choose different type to get better performance.\n\n\n```python\nfrom text_blind_watermark import TextBlindWatermark2\n\npassword = '20190808'\ntext = '\u8fd9\u53e5\u8bdd\u4e2d\u6709\u76f2\u6c34\u5370\uff0c\u4f60\u80fd\u63d0\u53d6\u51fa\u6765\u5417\uff1f'\nwatermark = 'github.com/guofei9987'\n\ntext_blind_wm = TextBlindWatermark2(password=password, chr_type=(3, 4))\n\ntext_with_wm = text_blind_wm.embed(text=text, watermark=watermark)\nprint(text_with_wm)\n\ntext_blind_wm2 = TextBlindWatermark2(password=password, chr_type=(3, 4))\nwm_extract = text_blind_wm2.extract(text_with_wm)\nprint('\u63d0\u53d6\u5185\u5bb9\uff1a', wm_extract)\nassert watermark == wm_extract\n```\n\n## Another algorithm is more robust\n\n### Alice Put her text watermark into a text:\n\n```python\nfrom text_blind_watermark import TextBlindWatermark\n\nwatermark = \"\u7edd\u5bc6\uff1a\u4e24\u70b9\u8001\u5730\u65b9\u89c1\uff01\"\ntext = \"\u8fd9\u53e5\u8bdd\u4e2d\u6709\u76f2\u6c34\u5370\uff0c\u4f60\u80fd\u63d0\u53d6\u51fa\u6765\u5417\uff1f\" * 16\npassword = \"20190808\"\n\ntwm = TextBlindWatermark(password=password)\ntwm.read_wm(watermark=watermark)\ntwm.read_text(text=text)\ntext_embed = twm.embed()\n\nprint(\"\u6253\u4e0a\u76f2\u6c34\u5370\u4e4b\u540e:\")\nprint(text_embed)\n```\n\nThen, you can paste this text to where you need.\n\n\n\n### Bob Extract the invisible watermark\n\n```python\nfrom text_blind_watermark import TextBlindWatermark\npassword = \"20190808\"\n\ntwm_new = TextBlindWatermark(password=password)\nwm_extract = twm_new.extract(text_embed)\nprint(\"\u89e3\u51fa\u7684\u76f2\u6c34\u5370\uff1a\")\nprint(wm_extract)\n```\n\n## Related Project\n\nHideInfo\uff1a[https://github.com/guofei9987/HideInfo](https://github.com/guofei9987/HideInfo)\n\n\n| \u7b97\u6cd5   | \u8bf4\u660e                |\n|------|-------------------|\n| [migrate tank](https://github.com/guofei9987/HideInfo/blob/main/example/example_mirage_tank.py) | \u4f7f\u56fe\u7247\u5728\u4e0d\u540c\u7684\u80cc\u666f\u4e0b\u663e\u793a\u4e0d\u540c\u7684\u56fe\u7247 |\n| [hide as image](https://github.com/guofei9987/HideInfo/blob/main/example/example_hide_as_img.py) | \u628a\u6570\u636e\u4ee5\u56fe\u7247\u5f62\u5f0f\u5b58\u653e        |\n| [hide in image](https://github.com/guofei9987/HideInfo/blob/main/example/example_hide_in_img.py) | \u628a\u6570\u636e\u85cf\u5728\u4e00\u4e2a\u56fe\u7247\u4e2d          |\n| [image seed](https://github.com/guofei9987/HideInfo/blob/main/example/example_img_seed.py)   | \u628a\u56fe\u7247\u548c\u6587\u4ef6\u9ecf\u5728\u4e00\u8d77\uff0c\u5e76\u5b58\u4e3a\u56fe\u7247  |\n| [EXIF](https://github.com/guofei9987/HideInfo/blob/main/example/example_img_exif.py) | \u628a\u4e00\u6bb5\u4fe1\u606f\u653e\u5230\u56fe\u7247\u7684EXIF\u4e2d   |\n| [hide as music](https://github.com/guofei9987/HideInfo/blob/main/example/example_hide_as_music.py) | \u628a\u6570\u636e\u4ee5\u97f3\u9891\u7684\u5f62\u5f0f\u5b58\u653e       |\n| [hide in music](https://github.com/guofei9987/HideInfo/blob/main/example/example_hide_in_music.py) | \u628a\u6570\u636e\u9690\u85cf\u5728\u4e00\u4e2a\u97f3\u9891\u4e2d       |\n| [hide as text](https://github.com/guofei9987/HideInfo/blob/main/example/example_hide_as_txt.py) | \u628a\u6570\u636e\u4ee5\u6587\u672c\u6587\u4ef6\u7684\u5f62\u5f0f\u5b58\u653e |\n| [hide in text](https://github.com/guofei9987/HideInfo/blob/main/example/example_hide_in_txt.py) | \u628a\u6570\u636e\u9690\u85cf\u5728\u4e00\u6bb5\u6587\u672c\u4e2d |\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Text Blind Watermark in Python",
    "version": "0.3.1",
    "project_urls": {
        "Homepage": "https://github.com/guofei9987/text_blind_watermark"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e94e429056b29a60abfd6df05a5252c1c24402f26aca4721a3274788ec03f674",
                "md5": "1980cea260345cafb84664f3d92a3bb9",
                "sha256": "f810b0331b06413944492b5061499bdb1dec77a292131d9a76b3543b163c778e"
            },
            "downloads": -1,
            "filename": "text_blind_watermark-0.3.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1980cea260345cafb84664f3d92a3bb9",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.5",
            "size": 5351,
            "upload_time": "2024-01-05T06:03:34",
            "upload_time_iso_8601": "2024-01-05T06:03:34.774266Z",
            "url": "https://files.pythonhosted.org/packages/e9/4e/429056b29a60abfd6df05a5252c1c24402f26aca4721a3274788ec03f674/text_blind_watermark-0.3.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "79519653e90ba2f937b50b83ddb9cc8e599254b9977c5c98471a855957f04d4a",
                "md5": "ee4c8e8c15b10b86cfc24c3106a60909",
                "sha256": "f08147ebc0d5506cb1ed90398355e7f87fc89b2e518299cebee01286126490fc"
            },
            "downloads": -1,
            "filename": "text_blind_watermark-0.3.1.tar.gz",
            "has_sig": false,
            "md5_digest": "ee4c8e8c15b10b86cfc24c3106a60909",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.5",
            "size": 5067,
            "upload_time": "2024-01-05T06:03:36",
            "upload_time_iso_8601": "2024-01-05T06:03:36.358693Z",
            "url": "https://files.pythonhosted.org/packages/79/51/9653e90ba2f937b50b83ddb9cc8e599254b9977c5c98471a855957f04d4a/text_blind_watermark-0.3.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-05 06:03:36",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "guofei9987",
    "github_project": "text_blind_watermark",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "text-blind-watermark"
}
        
Elapsed time: 0.16404s