Skip to main content

Swarmauri Community Captcha Generator Tool

Project description

Swarmauri Logo

PyPI - Downloads Hits PyPI - Python Version PyPI - License PyPI - swarmauri_tool_captchagenerator


Swarmauri Tool Captcha Generator

Tool that generates CAPTCHA images from text using the captcha library. Returns the rendered PNG as a base64-encoded string so it can be stored or embedded inline.

Features

  • Accepts a single parameter (text) and produces an ImageCaptcha output.
  • Returns a dictionary with image_b64 containing the PNG bytes encoded as base64.
  • Can be wired into larger Swarmauri toolchains to produce human challenges dynamically.

Prerequisites

  • Python 3.10 or newer.
  • Pillow and captcha dependencies (installed automatically with this package).

Installation

# pip
pip install swarmauri_tool_captchagenerator

# poetry
poetry add swarmauri_tool_captchagenerator

# uv (pyproject-based projects)
uv add swarmauri_tool_captchagenerator

Quickstart

import base64
from pathlib import Path
from swarmauri_tool_captchagenerator import CaptchaGeneratorTool

captcha_tool = CaptchaGeneratorTool()
result = captcha_tool("Verify42")

image_b64 = result["image_b64"]
image_bytes = base64.b64decode(image_b64)
Path("captcha.png").write_bytes(image_bytes)

Displaying inline (e.g., in a HTML response):

html = f"<img src='data:image/png;base64,{image_b64}' alt='captcha' />"

Tips

  • Customize CAPTCHA rendering (fonts, size) by subclassing and configuring ImageCaptcha (e.g., ImageCaptcha(width=280, height=90)).
  • Store the generated solution (Verify42 in the example) securely server-side to validate client responses later.
  • For high throughput, reuse the tool instance rather than instantiating per request to avoid repeated font loading overhead.

Want to help?

If you want to contribute to swarmauri-sdk, read up on our guidelines for contributing that will help you get started.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file swarmauri_tool_captchagenerator-0.9.0.dev22.tar.gz.

File metadata

  • Download URL: swarmauri_tool_captchagenerator-0.9.0.dev22.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for swarmauri_tool_captchagenerator-0.9.0.dev22.tar.gz
Algorithm Hash digest
SHA256 a41ae6fd4a1c14a4eb88cef7f7fe28aaf2a3ee8806e645732dbe350c0efb7fad
MD5 e08eafb126073a7999334d4bc2a5cc5c
BLAKE2b-256 41f0e535568d8c21c83f103a480aecd793c1a5459961674dba5484b86530101d

See more details on using hashes here.

File details

Details for the file swarmauri_tool_captchagenerator-0.9.0.dev22-py3-none-any.whl.

File metadata

  • Download URL: swarmauri_tool_captchagenerator-0.9.0.dev22-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for swarmauri_tool_captchagenerator-0.9.0.dev22-py3-none-any.whl
Algorithm Hash digest
SHA256 3940c3b1f00741d1772c54ea0a4ab182924f8c18682923710c9bde0585eb336d
MD5 d3584de25e990a8a798459d972189282
BLAKE2b-256 ec7b5e8a7954e48cf78f8a8778f8ee3cccef5152a7f532f231f01eabafb9b22d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page