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

swarmauri_tool_captchagenerator-0.9.0.tar.gz (7.2 kB view details)

Uploaded Source

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.tar.gz.

File metadata

  • Download URL: swarmauri_tool_captchagenerator-0.9.0.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.tar.gz
Algorithm Hash digest
SHA256 3721c0fb8cfab580229437bbe188ae4c2ce173f4767486d417fab1d76a980f09
MD5 fe5c2f2a8dcd7af24e28971f827df406
BLAKE2b-256 bbb4170ac4bb0ca70836f04d2cd429c4a64bbef92b32823e966afe8b69cf253b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: swarmauri_tool_captchagenerator-0.9.0-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-py3-none-any.whl
Algorithm Hash digest
SHA256 10b41e6de42bdf11efa943f9b69e6373d03ad0c3ca129b464f15b058f3edd741
MD5 e2eca3bbec0cd61cd28ea9ca79c28290
BLAKE2b-256 54a993b81f496adeb59a3f658488bc8a96cc8bb6053a0ac062d941cef105659c

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