discapty


Namediscapty JSON
Version 2.1.2 PyPI version JSON
download
home_pagehttps://github.com/Predeactor/DisCapTy
SummaryDisCapTy help you generate obfuscated images, leaving your code easy.
upload_time2023-02-03 15:57:46
maintainer
docs_urlNone
authorPredeactor
requires_python>=3.7,<4.0
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # DisCapTy

![DisCapTy's Logo](.github/logo.png#gh-dark-mode-only)![DisCapTy's Logo](.github/logo-dark.png#gh-light-mode-only)

DisCapTy is a highly type hinted Python module to generate Captcha images without struggling your mind on how to make your own. Everyone can use it!

**Documentation:** <https://discapty.readthedocs.io/>

<div align="center">
    <a href="https://pypi.org/project/DisCapTy/">
        <img src="https://img.shields.io/pypi/v/discapty?style=flat-square" alt="DisCapTy's Version" />
        <img src="https://img.shields.io/pypi/pyversions/discapty?style=flat-square" alt="Python Version Required" />
        <img src="https://img.shields.io/pypi/dm/discapty?color=blue&style=flat-square" alt="DisCapTy's download" />
    </a>
    <a href="https://discapty.readthedocs.io/en/latest/?badge=latest">
        <img src="https://readthedocs.org/projects/discapty/badge/?version=latest&style=flat-square" alt="Documentation Status" />
    </a>
</div>

## Installing

DisCapTy is available on PyPi!

```sh
pip3 install discapty
```

To use DisCapTy, you need a Python version equal or greater to `3.7` and below `3.11`.

## Clone & Test the project

This project is dependant of [Poetry](https://python-poetry.org), a dependency management tool. You are most likely going to require this tool to correctly interact with the project & its dependencies, check out [Poetry's documentation](https://python-poetry.org/docs) for how to install it.

To clone the repository: `git clone https://github.com/Predeactor/DisCapTy.git`

To install dependencies: `poetry install`

To run tests: `poetry run python -m unittest`

## Creating Captcha

For DisCapTy, a Captcha is simply a code with any possible objects that can be returned, for example, it is one code (Like "12345") with an image (Usually a `PIL.Image.Image` object)
This is because DisCapTy uses the concept of generators that are used to generate a captcha from a given code, and it can return anything.

DisCapTy comes with 3 builtin generators:

- TextGenerator : Text based captcha
- WheezyGenerator : Image based captcha
- ImageGenerator : Image based captcha

### Creating Captcha manually

```py
import discapty

def generate_a_captcha(initial_input: str) -> discapty.Captcha:
    # This generator returns an obfuscated text.
    captcha_for_user = discapty.TextGenerator().generate(initial_input)
    # Create a Captcha object, the first argument is the clear code, the second is the obfuscated code. Anything goes.
    return discapty.Captcha(initial_input, captcha_for_user)

# Generate your Captcha.
captcha = generate_a_captcha("12345")

# Show the obfuscated code. See https://discapty.readthedocs.io for more information on this object.
show_captcha_to_user(captcha.captcha)
```

### Checking user's input

```py
import discapty

# Generate your Captcha.
captcha: discapty.Captcha = generate_a_captcha("12345")

# This is your user's input here
user_input: str = '12345'

if captcha.check(user_input) is True:
    # The user input is correct
    print("Correct!")
else:
    # The user input is incorrect
    print("Incorrect!")
```

What's great with the `.check` method is that you can specify if you need to remove space in the user's input and/or check casing.

Creating Captcha manually is not a recommended way, because DisCapTy comes with its opinionated challenge runner & is inefficient anyway.

### Create a Challenge

```py
import discapty

challenge = discapty.Challenge(discapty.TextGenerator(), retries=3)

captcha = challenge.begin()

# We cannot provide typehint here, `captcha` is a `typing.Any` and cannot help you, it'll be your
# job to know what you'll get as a captcha.
send_captcha_to_user(captcha)
user_input: str = get_user_input()

is_correct: bool = challenge.check(user_input)
# If the user's input is correct, the challenge ends, if not, `challenge.attempted_tries` will get
# +1, and if it is greater than the retries that has been set, then an error is raised when using
# `.check`
```

Please see the [documentation](https://discapty.readthedocs.io/) for more information on how the library work.

## Contact

You can join my Discord server for any help: <https://discord.gg/aPVupKAxxP>

DisCapTy is an open-source project distributed under the MIT license:
![PyPI - License](https://img.shields.io/pypi/l/discapty?style=flat-square)

DisCapTy uses the [Roboto](https://fonts.google.com/specimen/Roboto) font as default font.
[This font](https://fonts.google.com/specimen/Roboto) is licensed under [Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0).

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Predeactor/DisCapTy",
    "name": "discapty",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7,<4.0",
    "maintainer_email": "",
    "keywords": "",
    "author": "Predeactor",
    "author_email": "predeactor0@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/9c/92/b99b5776af836e590f4cc62dcc1d1f76e6688ee8a92bb910d75e4be4691a/discapty-2.1.2.tar.gz",
    "platform": null,
    "description": "# DisCapTy\n\n![DisCapTy's Logo](.github/logo.png#gh-dark-mode-only)![DisCapTy's Logo](.github/logo-dark.png#gh-light-mode-only)\n\nDisCapTy is a highly type hinted Python module to generate Captcha images without struggling your mind on how to make your own. Everyone can use it!\n\n**Documentation:** <https://discapty.readthedocs.io/>\n\n<div align=\"center\">\n    <a href=\"https://pypi.org/project/DisCapTy/\">\n        <img src=\"https://img.shields.io/pypi/v/discapty?style=flat-square\" alt=\"DisCapTy's Version\" />\n        <img src=\"https://img.shields.io/pypi/pyversions/discapty?style=flat-square\" alt=\"Python Version Required\" />\n        <img src=\"https://img.shields.io/pypi/dm/discapty?color=blue&style=flat-square\" alt=\"DisCapTy's download\" />\n    </a>\n    <a href=\"https://discapty.readthedocs.io/en/latest/?badge=latest\">\n        <img src=\"https://readthedocs.org/projects/discapty/badge/?version=latest&style=flat-square\" alt=\"Documentation Status\" />\n    </a>\n</div>\n\n## Installing\n\nDisCapTy is available on PyPi!\n\n```sh\npip3 install discapty\n```\n\nTo use DisCapTy, you need a Python version equal or greater to `3.7` and below `3.11`.\n\n## Clone & Test the project\n\nThis project is dependant of [Poetry](https://python-poetry.org), a dependency management tool. You are most likely going to require this tool to correctly interact with the project & its dependencies, check out [Poetry's documentation](https://python-poetry.org/docs) for how to install it.\n\nTo clone the repository: `git clone https://github.com/Predeactor/DisCapTy.git`\n\nTo install dependencies: `poetry install`\n\nTo run tests: `poetry run python -m unittest`\n\n## Creating Captcha\n\nFor DisCapTy, a Captcha is simply a code with any possible objects that can be returned, for example, it is one code (Like \"12345\") with an image (Usually a `PIL.Image.Image` object)\nThis is because DisCapTy uses the concept of generators that are used to generate a captcha from a given code, and it can return anything.\n\nDisCapTy comes with 3 builtin generators:\n\n- TextGenerator : Text based captcha\n- WheezyGenerator : Image based captcha\n- ImageGenerator : Image based captcha\n\n### Creating Captcha manually\n\n```py\nimport discapty\n\ndef generate_a_captcha(initial_input: str) -> discapty.Captcha:\n    # This generator returns an obfuscated text.\n    captcha_for_user = discapty.TextGenerator().generate(initial_input)\n    # Create a Captcha object, the first argument is the clear code, the second is the obfuscated code. Anything goes.\n    return discapty.Captcha(initial_input, captcha_for_user)\n\n# Generate your Captcha.\ncaptcha = generate_a_captcha(\"12345\")\n\n# Show the obfuscated code. See https://discapty.readthedocs.io for more information on this object.\nshow_captcha_to_user(captcha.captcha)\n```\n\n### Checking user's input\n\n```py\nimport discapty\n\n# Generate your Captcha.\ncaptcha: discapty.Captcha = generate_a_captcha(\"12345\")\n\n# This is your user's input here\nuser_input: str = '12345'\n\nif captcha.check(user_input) is True:\n    # The user input is correct\n    print(\"Correct!\")\nelse:\n    # The user input is incorrect\n    print(\"Incorrect!\")\n```\n\nWhat's great with the `.check` method is that you can specify if you need to remove space in the user's input and/or check casing.\n\nCreating Captcha manually is not a recommended way, because DisCapTy comes with its opinionated challenge runner & is inefficient anyway.\n\n### Create a Challenge\n\n```py\nimport discapty\n\nchallenge = discapty.Challenge(discapty.TextGenerator(), retries=3)\n\ncaptcha = challenge.begin()\n\n# We cannot provide typehint here, `captcha` is a `typing.Any` and cannot help you, it'll be your\n# job to know what you'll get as a captcha.\nsend_captcha_to_user(captcha)\nuser_input: str = get_user_input()\n\nis_correct: bool = challenge.check(user_input)\n# If the user's input is correct, the challenge ends, if not, `challenge.attempted_tries` will get\n# +1, and if it is greater than the retries that has been set, then an error is raised when using\n# `.check`\n```\n\nPlease see the [documentation](https://discapty.readthedocs.io/) for more information on how the library work.\n\n## Contact\n\nYou can join my Discord server for any help: <https://discord.gg/aPVupKAxxP>\n\nDisCapTy is an open-source project distributed under the MIT license:\n![PyPI - License](https://img.shields.io/pypi/l/discapty?style=flat-square)\n\nDisCapTy uses the [Roboto](https://fonts.google.com/specimen/Roboto) font as default font.\n[This font](https://fonts.google.com/specimen/Roboto) is licensed under [Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0).\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "DisCapTy help you generate obfuscated images, leaving your code easy.",
    "version": "2.1.2",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4ba735c7022d1a0c24218398795e9d54bee34c4db7edb06a8fdfe93cbf789659",
                "md5": "1b97798b798d21f69364baa9ddda5dd4",
                "sha256": "95909a1f765b33b1fb98a50d54f24af885d60ff36c051578773a3f15d32f9a72"
            },
            "downloads": -1,
            "filename": "discapty-2.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1b97798b798d21f69364baa9ddda5dd4",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7,<4.0",
            "size": 109093,
            "upload_time": "2023-02-03T15:57:45",
            "upload_time_iso_8601": "2023-02-03T15:57:45.041986Z",
            "url": "https://files.pythonhosted.org/packages/4b/a7/35c7022d1a0c24218398795e9d54bee34c4db7edb06a8fdfe93cbf789659/discapty-2.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9c92b99b5776af836e590f4cc62dcc1d1f76e6688ee8a92bb910d75e4be4691a",
                "md5": "06bde1a1cc73c1f4ea9df92352b48f0b",
                "sha256": "b19afcc8f376343d211b56c79285d0049b371ec8a0fa637230c97fee67106c35"
            },
            "downloads": -1,
            "filename": "discapty-2.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "06bde1a1cc73c1f4ea9df92352b48f0b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7,<4.0",
            "size": 109601,
            "upload_time": "2023-02-03T15:57:46",
            "upload_time_iso_8601": "2023-02-03T15:57:46.386252Z",
            "url": "https://files.pythonhosted.org/packages/9c/92/b99b5776af836e590f4cc62dcc1d1f76e6688ee8a92bb910d75e4be4691a/discapty-2.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-02-03 15:57:46",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "Predeactor",
    "github_project": "DisCapTy",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "discapty"
}
        
Elapsed time: 0.56909s