{"id":46192462,"url":"https://github.com/innosoft-company/innocaptcha","last_synced_at":"2026-04-17T01:04:01.177Z","repository":{"id":341602022,"uuid":"1170756407","full_name":"InnoSoft-Company/InnoCaptcha","owner":"InnoSoft-Company","description":"A professional, pluggable CAPTCHA library with image, math, and custom challenge types, token-based security, and multiple storage backends.","archived":false,"fork":false,"pushed_at":"2026-03-05T03:46:47.000Z","size":238,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-05T05:02:17.651Z","etag":null,"topics":["bot-protection","captcha","innocaptcha","math-captcha","security","text-captcha"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/InnoSoft-Company.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-02T13:38:23.000Z","updated_at":"2026-03-05T04:03:50.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/InnoSoft-Company/InnoCaptcha","commit_stats":null,"previous_names":["innosoft-company/innocaptcha"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/InnoSoft-Company/InnoCaptcha","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InnoSoft-Company%2FInnoCaptcha","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InnoSoft-Company%2FInnoCaptcha/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InnoSoft-Company%2FInnoCaptcha/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InnoSoft-Company%2FInnoCaptcha/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/InnoSoft-Company","download_url":"https://codeload.github.com/InnoSoft-Company/InnoCaptcha/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InnoSoft-Company%2FInnoCaptcha/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30206334,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-06T19:07:06.838Z","status":"online","status_checked_at":"2026-03-07T02:00:06.765Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["bot-protection","captcha","innocaptcha","math-captcha","security","text-captcha"],"created_at":"2026-03-03T01:05:25.588Z","updated_at":"2026-04-17T01:04:01.122Z","avatar_url":"https://github.com/InnoSoft-Company.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# InnoCaptcha\r\n\r\n[![PyPI Version](https://img.shields.io/pypi/v/InnoCaptcha.svg)](https://pypi.org/project/InnoCaptcha/)\r\n[![Python Versions](https://img.shields.io/pypi/pyversions/InnoCaptcha.svg)](https://pypi.org/project/InnoCaptcha/)\r\n[![PyPI Status](https://img.shields.io/pypi/status/InnoCaptcha.svg)](https://pypi.org/project/InnoCaptcha/)\r\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/InnoSoft-Company/InnoCaptcha/blob/main/LICENSE)\r\n[![GitHub last commit](https://img.shields.io/github/last-commit/InnoSoft-Company/InnoCaptcha)](https://github.com/InnoSoft-Company/InnoCaptcha/commits/main)\r\n[![PyPI Downloads](https://img.shields.io/pypi/dm/InnoCaptcha)](https://pypi.org/project/InnoCaptcha/)\r\n[![Total Downloads](https://static.pepy.tech/personalized-badge/InnoCaptcha?period=total\u0026units=INTERNATIONAL_SYSTEM\u0026left_color=GRAY\u0026right_color=GREEN\u0026left_text=downloads)](https://pepy.tech/projects/InnoCaptcha)\r\n[![GitHub stars](https://img.shields.io/github/stars/InnoSoft-Company/InnoCaptcha?style=social)](https://github.com/InnoSoft-Company/InnoCaptcha)\r\n![Visitors Badge API](https://visitor-badge.laobi.icu/badge?page_id=InnoSoft-Company.InnoCaptcha\u0026style=flat)\r\n![Visitors - InnoCaptcha API](https://innocaptcha.midoghanam.site/api/analytics/ReposVisitorsCountShield/)\r\n\r\nA pluggable Python CAPTCHA library supporting image-based text challenges, arithmetic challenges, audio challenges, token-based security, and multiple storage backends.\r\n\r\n**[PyPI](https://pypi.org/project/InnoCaptcha/) · [GitHub](https://github.com/InnoSoft-Company/InnoCaptcha) · [Issues](https://github.com/InnoSoft-Company/InnoCaptcha/issues) · [Discussions](https://github.com/InnoSoft-Company/InnoCaptcha/discussions)**\r\n\r\n---\r\n\r\n## Table of Contents\r\n\r\n- [Installation](#installation)\r\n- [Quick Start](#quick-start)\r\n  - [Text CAPTCHA](#1-text-captcha)\r\n  - [Math CAPTCHA](#2-math-captcha)\r\n  - [Audio CAPTCHA](#3-audio-captcha)\r\n  - [Image CAPTCHA](#4-image-captcha)\r\n  - [Command-Line Interface](#5-command-line-interface)\r\n- [API Reference](#api-reference)\r\n- [Requirements](#requirements)\r\n- [License](#license)\r\n\r\n---\r\n\r\n## Installation\r\n\r\n```bash\r\npip install InnoCaptcha\r\n```\r\n\r\n---\r\n\r\n## Quick Start\r\n\r\n### 1. Text CAPTCHA\r\n\r\nGenerates an image-based CAPTCHA with configurable text, colors, and dimensions. All images include random distortions and anti-aliasing.\r\n\r\n```python\r\nfrom InnoCaptcha.text import TextCaptcha\r\n\r\n# Basic usage\r\ncaptcha = TextCaptcha()\r\ncaptcha.create(\"abs\")\r\nprint(captcha.verify(\"abs\"))    # True\r\ncaptcha.save(r\"captcha.png\")\r\n\r\n# Custom dimensions and colors\r\ncaptcha = TextCaptcha(\r\n    width=350,\r\n    height=100,\r\n    color=(255, 137, 6),\r\n    background=(15, 14, 23)\r\n)\r\ncaptcha.create()\r\nprint(captcha.verify('Answer'))\r\ncaptcha.save(r\"captcha.jpg\")\r\n```\r\n\r\n**Constructor Parameters**\r\n\r\n| Parameter    | Type                   | Default        | Description                     |\r\n|--------------|------------------------|----------------|---------------------------------|\r\n| `width`      | `int` or `None`        | `300`          | Image width in pixels.          |\r\n| `height`     | `int` or `None`        | `80`           | Image height in pixels.         |\r\n| `color`      | `tuple[int, int, int]` | `Random color` | Foreground (text) color in RGB. |\r\n| `background` | `tuple[int, int, int]` | `Random color` | Background color in RGB.        |\r\n\r\n**`create(chars: str)`** — The text string to render in the CAPTCHA image. Optional.\r\n\r\n**`save()` Parameters**\r\n\r\n| Parameter | Type  | Default         | Description                                     |\r\n|-----------|-------|-----------------|-------------------------------------------------|\r\n| `path`    | `str` | `'captcha.png'` | Full file path or file name to write the image. |\r\n\r\n\u003e **Notes:**\r\n\u003e - Uses `secrets` for cryptographically strong randomness.\r\n\u003e - Rendering can be tuned via module-level constants such as `CHARACTER_OFFSET_DX` and `WORD_SPACE_PROBABILITY`.\r\n\r\n---\r\n\r\n### 2. Math CAPTCHA\r\n\r\nGenerates arithmetic challenges (addition, subtraction, multiplication, division). All results are integers — the problem regenerates automatically if division would produce a fraction. Can output as plain text or an image.\r\n\r\n```python\r\nfrom InnoCaptcha.math import MathCaptcha\r\n\r\n# Text output (default)\r\nchallenge = MathCaptcha()\r\nprint(challenge.get_question())  # e.g., \"7 + 3 = ?\"\r\nprint(challenge.answer)          # e.g., \"10\"\r\n\r\n# Image output\r\nimage_challenge = MathCaptcha(output=\"image\")\r\nimage_challenge.get_question().show() # Returns a PIL.Image\r\n\r\nprint(challenge.verify(10))      # True\r\nprint(challenge.verify(\"10\"))    # True — string input accepted\r\n```\r\n\r\n---\r\n\r\n### 3. Audio CAPTCHA\r\n\r\nGenerates a spoken character sequence as a WAV file. Each character is spliced from pre-recorded audio samples stored in the `data/` directory, with per-character noise injection, randomized playback speed, and a low-pass filter applied to the combined output. Challenge state is persisted in SQLite with a 5-minute expiry and a 5-attempt limit.\r\n\r\n```python\r\nfrom InnoCaptcha.audio import AudioCaptcha\r\n\r\n# Basic usage\r\ncaptcha = AudioCaptcha()\r\ncaptcha.create(\"ab3\")\r\ncaptcha.save(\"captcha.wav\")\r\n\r\nprint(captcha.verify(\"ab3\"))    # True\r\nprint(captcha.verify(\"wrong\"))  # False\r\n```\r\n\r\n**`create(chars: str)`** — Accepts up to 6 characters. Each character must have a corresponding `\u003cchar\u003e.wav` file in the `data/` directory. Raises `FileNotFoundError` if any file is missing.\r\n\r\n**`save()` Parameters**\r\n\r\n| Parameter | Type  | Default | Description                                  |\r\n|-----------|-------|---------|----------------------------------------------|\r\n| `path`    | `str` | —       | Full file path to write the output WAV file. |\r\n\r\n**`verify(user_input: str) -\u003e bool or str`**\r\n\r\n| Return value          | Condition                                                |\r\n|-----------------------|----------------------------------------------------------|\r\n| `True`                | Input matches the stored answer (case-insensitive).      |\r\n| `False`               | Input does not match; attempt counter incremented.       |\r\n| `str` (error message) | Captcha expired or maximum attempts (5) reached.         |\r\n\r\n\u003e **Notes:**\r\n\u003e - Uses `secrets` for randomness in noise generation and speed variation.\r\n\u003e - A background thread runs on instantiation to purge expired records from the database.\r\n\u003e - Output is a 44100 Hz, 16-bit, mono WAV file.\r\n\r\n---\r\n\r\n### 4. Image CAPTCHA\r\n\r\nPresents a 3×3 grid overlay on a randomly selected image. The user identifies which grid cells contain the target object. Detection is performed using YOLOv11n — cells are marked correct if any detected bounding box overlaps them. Challenge state is persisted in SQLite with a 5-minute expiry and a 6-attempt limit.\r\n\r\n```python\r\nfrom InnoCaptcha.image import ImageCaptcha\r\n\r\ncaptcha = ImageCaptcha()\r\ncaptcha.create()\r\nprint(captcha.verify())  # True, False, or str on expiry/lockout\r\n```\r\n\r\n**`create()`** — Loads a random image from the dataset, runs YOLO inference to locate objects, and draws a 3×3 blue grid over the result. Must be called before `verify()`.\r\n\r\n**`verify() -\u003e bool or str`** — Displays the gridded image and prompts the user to enter the cell numbers (1–9, comma-separated) containing the detected object. Returns `True` only if the submitted cells exactly match all cells that overlap a detected bounding box.\r\n\r\n**`verify(user_input: str) -\u003e bool or str`**\r\n\r\n| Return value          | Condition                                                |\r\n|-----------------------|----------------------------------------------------------|\r\n| `True`                | Submitted cells exactly match all detected object cells. |\r\n| `False`               | Input does not match; attempt counter incremented.       |\r\n| `str` (error message) | Captcha expired or maximum attempts (6) reached.         |\r\n\r\n\u003e **Notes:**\r\n\u003e - Grid numbering is row-major: 1–3 top row, 4–6 middle row, 7–9 bottom row.\r\n\u003e - Image dataset must be structured as `data/images/\u003cclass\u003e/\u003cfilename\u003e`.\r\n\u003e - Uses `secrets` for random image selection.\r\n\u003e - A background thread runs on instantiation to purge expired records from the database.\r\n\r\n---\r\n\r\n### 5. Command-Line Interface\r\n\r\n```bash\r\n# Display the installed version\r\nInnoCaptcha --version\r\n\r\n# Upgrade to the latest release on PyPI\r\nInnoCaptcha --upgrade\r\n```\r\n\r\n---\r\n\r\n## API Reference\r\n\r\n### `TextCaptcha`\r\n\r\n| Method / Attribute   | Description                                              |\r\n|----------------------|----------------------------------------------------------|\r\n| `create(chars: str)` | Renders the given string into a distorted CAPTCHA image. |\r\n| `verify(input: str)` | Returns `True` if `input` matches the generated text.    |\r\n| `save(path)`         | Writes the image to the specified file path.             |\r\n\r\n### `MathCaptcha`\r\n\r\n| Method / Attribute      | Description                                          |\r\n|-------------------------|------------------------------------------------------|\r\n| `get_question() -\u003e str \\| PIL.Image.Image` | Returns the challenge string (e.g. `\"7 + 3 = ?\"`) or a rendered PIL Image if `output=\"image\"`.   |\r\n| `answer: str`           | The correct string integer answer to the current challenge. |\r\n| `verify(input) -\u003e bool` | Returns `True` if `input` equals the answer.         |\r\n\r\n### `AudioCaptcha`\r\n\r\n| Method / Attribute   | Description                                                                       |\r\n|----------------------|-----------------------------------------------------------------------------------|\r\n| `create(chars: str)` | Builds the audio challenge from up to 6 characters using per-character WAV files. |\r\n| `verify(input: str)` | Returns `True` on match, `False` on mismatch, or a `str` on expiry/lockout.      |\r\n| `save(path: str)`    | Writes the generated audio to a 44100 Hz 16-bit mono WAV file.                   |\r\n| `id: str`            | The hex token identifying this challenge in the database.                         |\r\n| `audio: np.ndarray`  | Raw float32 audio samples; `None` until `create()` is called.                    |\r\n\r\n### `ImageCaptcha`\r\n\r\n| Method / Attribute       | Description                                                              |\r\n|--------------------------|--------------------------------------------------------------------------|\r\n| `create()`               | Runs YOLO detection on a random dataset image and overlays a 3×3 grid.  |\r\n| `verify() -\u003e bool or str`| Displays the image, accepts grid input, returns `True` on exact match.  |\r\n| `id: str`                | The hex token identifying this challenge in the database.                |\r\n| `image_class: str`       | The randomly selected object class for the current challenge.            |\r\n| `annotation_coordinates` | List of `(x1, y1, x2, y2)` bounding boxes from YOLO inference.          |\r\n\r\n---\r\n\r\n## Requirements\r\n\r\n- Python 3.9 or later\r\n- Pillow \u003e= 10.0.0\r\n- numpy\r\n- scipy\r\n- ultralytics\r\n- opencv-python\r\n\r\n---\r\n\r\n## License\r\n\r\nMIT — [InnoSoft Company](https://github.com/InnoSoft-Company)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finnosoft-company%2Finnocaptcha","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finnosoft-company%2Finnocaptcha","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finnosoft-company%2Finnocaptcha/lists"}