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

File metadata

  • Download URL: swarmauri_tool_captchagenerator-0.9.3.dev3.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.3 {"installer":{"name":"uv","version":"0.10.3","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.3.dev3.tar.gz
Algorithm Hash digest
SHA256 63094700ca4c0a353e4bbf5f0934aadfdf504febe4b77329ec0cd53e79483e09
MD5 141b32d3cc14f02fa2b28374a311de4f
BLAKE2b-256 f5fb3d9d1d4e091a59cf11a147cbcae37c59f65e3b4f4d5b1fbc7628af9fa62d

See more details on using hashes here.

File details

Details for the file swarmauri_tool_captchagenerator-0.9.3.dev3-py3-none-any.whl.

File metadata

  • Download URL: swarmauri_tool_captchagenerator-0.9.3.dev3-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.3 {"installer":{"name":"uv","version":"0.10.3","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.3.dev3-py3-none-any.whl
Algorithm Hash digest
SHA256 9dbc396f73662fec005929164b1ba3850748b32b8bba1fff3e170bf75505d91d
MD5 98d1acf3cdca6887a565d1a16b8506d4
BLAKE2b-256 941499bcdc380e8d6efeeee2f13e793c54087a2aaa5058941a1d4f0d84de136d

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