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

File metadata

  • Download URL: swarmauri_tool_captchagenerator-0.10.0.dev7.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.dev7.tar.gz
Algorithm Hash digest
SHA256 ef8d8d4f8f4f96d2064f6474929f2cd6d36946a2406eab9d175ab9283e4f3277
MD5 e93b5d2a7ebe30066314495ae973b370
BLAKE2b-256 433ff16776f610cd168932de677d1d311b7fbfee280b7ac6a0b153eeb962ed65

See more details on using hashes here.

File details

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

File metadata

  • Download URL: swarmauri_tool_captchagenerator-0.10.0.dev7-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.dev7-py3-none-any.whl
Algorithm Hash digest
SHA256 bddff8a391f71732e39cfb5dfe66a5c570de2f2dc1124af18b1d20042c159327
MD5 ea0822d5632fb2b0a079ad9cfc4a2b37
BLAKE2b-256 6aacc452a83e585c7baf5be4a58fad3080bbdc354223b011ef1e7695255f6c29

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