color-captcha


Namecolor-captcha JSON
Version 0.1.5 PyPI version JSON
download
home_pageNone
SummaryDynamically generated, AI-resistant captcha images
upload_time2024-09-21 01:43:32
maintainerNone
docs_urlNone
authorStefan Stojanovic
requires_python>=3.9
licenseMIT License Copyright (c) 2024 Stefan Stojanovic Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords captcha captcha-generator captcha-image clock digital python
VCS
bugtrack_url
requirements pillow
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # color-captcha
Dynamically generated, AI-resistant captcha images. 

![color-captcha](https://raw.githubusercontent.com/stefs304/clockcaptcha/master/color-captcha.png)

*Can you tell what time it is? AI can't.*

Color-captcha uses higher-order shapes to hide the information from AI. 
AI can recognize that the image is made up of triangles, squares and circles.
However, it cannot recognize that these shapes form more complex higher-order shapes, in this case numbers. 
The numbers, therefore, remain hidden in plain sight.
The human eye, on the other hand, should be able to see the numbers with little effort. 

Features:
* `ClockCaptcha` and `DigitsCaptcha` generators.
* Decently performant: can generate 100 images in ~0.8 seconds.
* Configurable (base colors, color variation).

### Installation

```shell
pip install color-captcha
```

### Usage

#### ClockCaptcha

```python
from color_captcha import ClockCaptcha

captcha = ClockCaptcha(clock_mode=12, color_mode='rgb') 
# 12 or 24-hour mode
# rgb or grayscale color_mode

# current captcha value
print(captcha.value)

captcha.save_image('my_captcha.png') 
# if no extension, set format explicitly
captcha.save_image('my_captcha', format='png')

# verify the guessed value
captcha.verify('0645') 
# returns True/False

# create new captcha
captcha.generate_new()
captcha.save_image('new_captcha.png')
```

#### DigitsCaptcha
Same usage as ClockCaptcha except it generates captcha with arbitrary number of 
digits, and is not in the clock format, just plain digits. 

```python
from color_captcha import DigitsCaptcha

captcha = DigitsCaptcha(digits=5)
captcha.save_image('digits.png')
captcha.verify('12345')
captcha.generate_new()
```

#### Size parameter
Both ClockCaptcha and DigitsCaptcha have the `size` parameter, which changes the size of the image.
Below relative values in pixels for the ClockCaptcha image. 
DigitsCaptcha images vary in width depending on the number of digits. 

ClockCaptcha sizes:

| size            | width (pixels) | height (pixels) |
|-----------------|----------------|-----------------|
| 1               | 190            | 65              |
| 2               | 380            | 130             |
| **3 (default)** | **570**        | **195**         |
| 4               | 760            | 260             |
| ...             | ...            | ...             | 

### Changing configuration
Configuration changes are applied globally.
* `colors`: list of base colors in hex format (full 6 characters required).
* `base_variation_percent`: max \*variation of the color in the background.  
* `content_variation_percent`: max \*variation of colors of the numbers.

\*Percent increase of non-dominant colors in a pixel.
To turn off color variation set these parameters to 0.

```python
from color_captcha.config import Config

Config.colors = ['#ec7063', '...']
Config.base_variation_percent = 0.30
Config.content_variation_percent = 0.15
```

⚠️ **Important to consider:** 
Difference in color variation between background and numbers can make the numbers stand out more. 
If this difference is too great the AI may pick up on that and be able to detect numbers. 
The default values of 0.15 and 0.30 should be good for now, but may need to change in the future. 


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "color-captcha",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "captcha, captcha-generator, captcha-image, clock, digital, python",
    "author": "Stefan Stojanovic",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/1e/40/2b60114ec234f21d55722f12ac500a0322a005f352b7686b513ad1c9821f/color_captcha-0.1.5.tar.gz",
    "platform": null,
    "description": "# color-captcha\nDynamically generated, AI-resistant captcha images. \n\n![color-captcha](https://raw.githubusercontent.com/stefs304/clockcaptcha/master/color-captcha.png)\n\n*Can you tell what time it is? AI can't.*\n\nColor-captcha uses higher-order shapes to hide the information from AI. \nAI can recognize that the image is made up of triangles, squares and circles.\nHowever, it cannot recognize that these shapes form more complex higher-order shapes, in this case numbers. \nThe numbers, therefore, remain hidden in plain sight.\nThe human eye, on the other hand, should be able to see the numbers with little effort. \n\nFeatures:\n* `ClockCaptcha` and `DigitsCaptcha` generators.\n* Decently performant: can generate 100 images in ~0.8 seconds.\n* Configurable (base colors, color variation).\n\n### Installation\n\n```shell\npip install color-captcha\n```\n\n### Usage\n\n#### ClockCaptcha\n\n```python\nfrom color_captcha import ClockCaptcha\n\ncaptcha = ClockCaptcha(clock_mode=12, color_mode='rgb') \n# 12 or 24-hour mode\n# rgb or grayscale color_mode\n\n# current captcha value\nprint(captcha.value)\n\ncaptcha.save_image('my_captcha.png') \n# if no extension, set format explicitly\ncaptcha.save_image('my_captcha', format='png')\n\n# verify the guessed value\ncaptcha.verify('0645') \n# returns True/False\n\n# create new captcha\ncaptcha.generate_new()\ncaptcha.save_image('new_captcha.png')\n```\n\n#### DigitsCaptcha\nSame usage as ClockCaptcha except it generates captcha with arbitrary number of \ndigits, and is not in the clock format, just plain digits. \n\n```python\nfrom color_captcha import DigitsCaptcha\n\ncaptcha = DigitsCaptcha(digits=5)\ncaptcha.save_image('digits.png')\ncaptcha.verify('12345')\ncaptcha.generate_new()\n```\n\n#### Size parameter\nBoth ClockCaptcha and DigitsCaptcha have the `size` parameter, which changes the size of the image.\nBelow relative values in pixels for the ClockCaptcha image. \nDigitsCaptcha images vary in width depending on the number of digits. \n\nClockCaptcha sizes:\n\n| size            | width (pixels) | height (pixels) |\n|-----------------|----------------|-----------------|\n| 1               | 190            | 65              |\n| 2               | 380            | 130             |\n| **3 (default)** | **570**        | **195**         |\n| 4               | 760            | 260             |\n| ...             | ...            | ...             | \n\n### Changing configuration\nConfiguration changes are applied globally.\n* `colors`: list of base colors in hex format (full 6 characters required).\n* `base_variation_percent`: max \\*variation of the color in the background.  \n* `content_variation_percent`: max \\*variation of colors of the numbers.\n\n\\*Percent increase of non-dominant colors in a pixel.\nTo turn off color variation set these parameters to 0.\n\n```python\nfrom color_captcha.config import Config\n\nConfig.colors = ['#ec7063', '...']\nConfig.base_variation_percent = 0.30\nConfig.content_variation_percent = 0.15\n```\n\n\u26a0\ufe0f **Important to consider:** \nDifference in color variation between background and numbers can make the numbers stand out more. \nIf this difference is too great the AI may pick up on that and be able to detect numbers. \nThe default values of 0.15 and 0.30 should be good for now, but may need to change in the future. \n\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2024 Stefan Stojanovic  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "Dynamically generated, AI-resistant captcha images",
    "version": "0.1.5",
    "project_urls": {
        "Homepage": "https://github.com/stefs304/color-captcha",
        "Issues": "https://github.com/stefs304/color-captcha/issues"
    },
    "split_keywords": [
        "captcha",
        " captcha-generator",
        " captcha-image",
        " clock",
        " digital",
        " python"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5eba66ba9c0c4bdedf2c422745aeffa91d4c77cec256662f0a297cee3dd59788",
                "md5": "975eb4065277c0d4ef54cc7510226198",
                "sha256": "b3c3979df3db7d4ab274f1f8a5b550ad96ba7af930dd10710c8d69789bd930c3"
            },
            "downloads": -1,
            "filename": "color_captcha-0.1.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "975eb4065277c0d4ef54cc7510226198",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 7539,
            "upload_time": "2024-09-21T01:43:31",
            "upload_time_iso_8601": "2024-09-21T01:43:31.276450Z",
            "url": "https://files.pythonhosted.org/packages/5e/ba/66ba9c0c4bdedf2c422745aeffa91d4c77cec256662f0a297cee3dd59788/color_captcha-0.1.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1e402b60114ec234f21d55722f12ac500a0322a005f352b7686b513ad1c9821f",
                "md5": "988313020d79c76213bf63a2df7ff32d",
                "sha256": "9b860efd5f588a1326adc11c71db68bd6dad91d376fa1d293a9071758a5ebe4a"
            },
            "downloads": -1,
            "filename": "color_captcha-0.1.5.tar.gz",
            "has_sig": false,
            "md5_digest": "988313020d79c76213bf63a2df7ff32d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 33228,
            "upload_time": "2024-09-21T01:43:32",
            "upload_time_iso_8601": "2024-09-21T01:43:32.608484Z",
            "url": "https://files.pythonhosted.org/packages/1e/40/2b60114ec234f21d55722f12ac500a0322a005f352b7686b513ad1c9821f/color_captcha-0.1.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-21 01:43:32",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "stefs304",
    "github_project": "color-captcha",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "pillow",
            "specs": []
        }
    ],
    "lcname": "color-captcha"
}
        
Elapsed time: 1.37973s