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

File metadata

  • Download URL: swarmauri_tool_captchagenerator-0.10.0.dev1.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","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.10.0.dev1.tar.gz
Algorithm Hash digest
SHA256 b7040f227e9e6d96ea827648ad40850b143e81e98deb528dec0ff169a99ff03a
MD5 780f402e535a1ed2c8714e9f24503bd3
BLAKE2b-256 f8cade6ce6f7d35abb059c18ec8f437ae32af8cebd0a443eafda5504eb2defa3

See more details on using hashes here.

File details

Details for the file swarmauri_tool_captchagenerator-0.10.0.dev1-py3-none-any.whl.

File metadata

  • Download URL: swarmauri_tool_captchagenerator-0.10.0.dev1-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","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.10.0.dev1-py3-none-any.whl
Algorithm Hash digest
SHA256 f984b1720dc9caaba8637d91a2f9072de26b4c68c510b20326debe232b458b77
MD5 3cf4fb7e2ff4b49e76a11720e5953189
BLAKE2b-256 a7135dd8fdc92499b9b7ba3a96a9794964f5bbe690f87fba1f37e8acc8d335dd

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