Skip to main content

InnoCaptcha

PyPI Version Python Versions PyPI Status License: MIT GitHub last commit PyPI Downloads Total Downloads GitHub stars Visitors Badge API Visitors - InnoCaptcha API

InnoCaptcha is a professional, pluggable Python CAPTCHA library designed for modern web applications. It supports multiple challenge types, from traditional text and math to advanced audio, image-based grid challenges (using YOLOv11), and voice recognition challenges.


🌟 Key Features

  • 📝 Text CAPTCHA: Highly configurable image-based text challenges with anti-aliasing and distortion.
  • 🔢 Math CAPTCHA: Secure arithmetic problems (no eval()) with optional image rendering.
  • 🎧 Audio CAPTCHA: Spoken character sequences with noise injection and variable speed.
  • 🗣️ Voice CAPTCHA (STT): Speech-to-text challenges where users must speak a random phrase.
  • 🖼️ Image CAPTCHA (YOLOv11): Advanced 3×3 grid challenges using Object Detection.
  • 🔐 Security First:
    • Token-based challenge identification.
    • IP and Session binding for verification safety.
    • Automatic expiration (5 minutes) and attempt limits (5 attempts).
    • Synchronous cleanup for expired challenges to prevent memory leaks.
    • Secure data encryption via INNOCAPTCHA_KEY.
  • 🗄️ Storage: Centralized SQLite database management.

🚀 Installation

pip install InnoCaptcha

🛠️ Quick Start

Important: For production, please set the INNOCAPTCHA_KEY environment variable to a secure Fernet key to encrypt answers in the database.

export INNOCAPTCHA_KEY="your_secure_fernet_key_here"

1. Text CAPTCHA

Generates a distorted image containing a random string.

from InnoCaptcha.text import TextCaptcha

captcha = TextCaptcha(width=300, height=80)
# Pass IP and session ID for context binding
captcha_id = captcha.create("abcd", ip="127.0.0.1", session_id="abc123xyz")
captcha.save("captcha.png")

print(captcha.verify("abcd", ip="127.0.0.1", session_id="abc123xyz")) # Returns True

2. Math CAPTCHA

Generates arithmetic challenges. Can be output as plain text or a rendered image.

from InnoCaptcha.math import MathCaptcha

# Image-based Math Challenge
math_cap = MathCaptcha(output="image")
math_cap.create(ip="127.0.0.1", session_id="abc123xyz")
math_cap.get_question().show() # Returns a PIL Image

# Answer depends on the generated math question
print(math_cap.verify("12", ip="127.0.0.1", session_id="abc123xyz"))

3. Audio CAPTCHA

Generates a WAV file where a voice reads out characters.

from InnoCaptcha.audio import AudioCaptcha

audio = AudioCaptcha()
audio.create("x123", ip="127.0.0.1")
audio.save("output.wav")

print(audio.verify("x123", ip="127.0.0.1"))

4. Voice CAPTCHA (New!)

A speech-to-text challenge. The user is given a phrase and must submit a recording of them speaking it.

from InnoCaptcha.voice import VoiceCaptcha

vc = VoiceCaptcha(language='en-US')
captcha_id = vc.create(ip="127.0.0.1") 
print(f"Please read: {vc.phrase}")

# ... User records audio and sends bytes ...
audio_bytes = open("user_speech.wav", "rb").read()
is_correct = vc.verify(audio_bytes, ip="127.0.0.1")

5. Image CAPTCHA (YOLOv11)

Uses YOLOv11 to detect objects in an image and asks the user to select the grid cells (1-9).

from InnoCaptcha.image import ImageCaptcha

img_cap = ImageCaptcha()
img_cap.create(ip="127.0.0.1")
img_cap.save("grid_image.png")
print(f"Target object to detect: {img_cap.image_class}")

# User inputs cell numbers, e.g., "1,2,5"
print(img_cap.verify("1,2,5", ip="127.0.0.1"))

💎 API Reference

Component Description
TextCaptcha Classic image-text challenges. Supports custom colors/scaling.
MathCaptcha Arithmetic challenges (+, -, *). Supports text or image output.
AudioCaptcha Generates character-based audio files for auditory verification.
VoiceCaptcha Speech-to-text verification using speech_recognition.
ImageCaptcha AI-powered grid identification using YOLOv11.

🆙 Latest Updates (v2.3.x)

  • New Security & Architecture Audit Fixes:
    • Addressed memory leaks by removing background threading loops per instance.
    • Patched an SQL injection via ALLOWED_TABLES whitelisting.
    • Eliminated timing attacks across all context verifications using secrets.compare_digest.
    • Moved DB Encryption to require an INNOCAPTCHA_KEY variable, keeping the encryption key out of the SQLite DB itself.
    • Implemented atomic updates for attempt counters to eliminate race conditions.
    • Optimized ImageCaptcha to use a global cached singleton for its YOLOv11 model, vastly speeding up subsequent initializations.

📜 Requirements

  • Python 3.9+
  • Dependencies: Pillow, numpy, scipy, ultralytics, opencv-python, pydub, SpeechRecognition, etc.

📄 License

MIT © InnoSoft Company

Release files for InnoCaptcha 2.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for InnoCaptcha 2.4.0
File Size Uploaded
innocaptcha-2.4.0.tar.gz 7.3 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for InnoCaptcha 2.4.0
File Interpreter ABI Platform
innocaptcha-2.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 14.6 MB

Release files / innocaptcha-2.4.0.tar.gz

Download URL innocaptcha-2.4.0.tar.gz
Size 7.3 MB
Tags Source
SHA-256 checksum
How to use checksums
67136f13e5cd38ac52ac2f42d322809cc36bc8c0826703f17a2c18e5ff3b6f45
BLAKE2b-256 checksum
How to use checksums
3ea99818e86ff844ca3c40bf27b838d08e3900bd8d976217e00d2cde8b314fad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release files / innocaptcha-2.4.0-py3-none-any.whl

Download URL innocaptcha-2.4.0-py3-none-any.whl
Size 7.3 MB
Tags Python 3
SHA-256 checksum
How to use checksums
dbe9fcc152e4b562989bc82b5dbae0eacd94688f9605509115c557e0bed7c719
BLAKE2b-256 checksum
How to use checksums
7d10f682580917021845ea9b893ff1f83f6c861459fe530a9025cd08fc0ec209
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release history Release notifications | RSS feed

This release

2.4.0 This release

2 release files

2.3.0

2 release files

2.2.1

2 release files

2.2.0

2 release files

2.1.0

2 release files

2.0.0

2 release files

1.2.0

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page