light-captcha


Namelight-captcha JSON
Version 0.0.1 PyPI version JSON
download
home_pagehttps://github.com/COD332/light-captcha
SummaryA lightweight CAPTCHA generator for Persian and English digits
upload_time2025-07-20 20:52:29
maintainerNone
docs_urlNone
authorAlireza Esameilzadeh
requires_python>=3.7
licenseMIT
keywords captcha persian english security image generation
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Light Captcha

A lightweight Python library for generating CAPTCHA images with Persian (۰-۹) and English (0-9) digits.

## Features

- ✨ Support for both Persian and English numerals
- 🔒 Random digit skewing and rotation for security
- 📏 Size variations for enhanced difficulty  
- 🎯 Millisecond-based random number generation
- 🌊 Wave distortion effects
- 🎨 Random color schemes
- 🔧 Enhanced noise and interference patterns
- 📐 Customizable image dimensions

## Installation

```bash
pip install light-captcha
```

## Quick Start

```python
from light_captcha import CaptchaGenerator

# Create generator instance
generator = CaptchaGenerator()

# Generate English CAPTCHA
image, number = generator.generate('english')
image.save('captcha_english.png')
print(f"Generated number: {number}")

# Generate Persian CAPTCHA
image, number = generator.generate('persian')
image.save('captcha_persian.png')
print(f"Generated number: {number}")
```

## Usage Examples

### Custom Dimensions

```python
# Generate with custom size
image, number = generator.generate('english', width=300, height=100)
```

### Custom Colors

```python
# Generate with custom colors
bg_color = (240, 248, 255)  # Light blue background
text_color = (25, 25, 112)   # Navy text
image, number = generator.generate(
    'english', 
    bg_color=bg_color, 
    text_color=text_color
)
```

### Batch Generation

```python
generator = CaptchaGenerator()

# Generate multiple CAPTCHAs
for i in range(10):
    image, number = generator.generate('persian')
    image.save(f'captcha_{i}.png')
    print(f"CAPTCHA {i}: {number}")
```

## API Reference

### CaptchaGenerator

#### `generate(language, width=250, height=80, bg_color=None, text_color=None)`

Generate a CAPTCHA image.

**Parameters:**
- `language` (str): `'english'` or `'persian'`
- `width` (int): Image width in pixels (default: 250)
- `height` (int): Image height in pixels (default: 80)  
- `bg_color` (tuple, optional): RGB background color
- `text_color` (tuple, optional): RGB text color

**Returns:**
- `tuple`: (PIL Image object, 6-digit string)

**Raises:**
- `ValueError`: If language is not 'english' or 'persian'
- `FileNotFoundError`: If required font file is missing

## Security Features

- **Random Skewing**: Each digit rotated -15° to +15°
- **Size Variation**: Random scaling 0.8x to 1.2x per digit
- **Wave Distortion**: Sinusoidal distortion across the image
- **Noise Patterns**: Curved lines and random dots
- **Color Randomization**: Multiple predefined color schemes
- **Millisecond Seeding**: High-precision random generation

## Requirements

- Python 3.7+
- Pillow >= 8.0.0

## License

MIT License - see LICENSE file for details.

## Contributing

Issues and pull requests are welcome on [GitHub](https://github.com/COD332/light-captcha).

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/COD332/light-captcha",
    "name": "light-captcha",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "captcha, persian, english, security, image, generation",
    "author": "Alireza Esameilzadeh",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/96/3c/7f33b2575c307ebd4221f62759227a16feab40181994a2ec01d15ef6a7b3/light_captcha-0.0.1.tar.gz",
    "platform": null,
    "description": "# Light Captcha\n\nA lightweight Python library for generating CAPTCHA images with Persian (\u06f0-\u06f9) and English (0-9) digits.\n\n## Features\n\n- \u2728 Support for both Persian and English numerals\n- \ud83d\udd12 Random digit skewing and rotation for security\n- \ud83d\udccf Size variations for enhanced difficulty  \n- \ud83c\udfaf Millisecond-based random number generation\n- \ud83c\udf0a Wave distortion effects\n- \ud83c\udfa8 Random color schemes\n- \ud83d\udd27 Enhanced noise and interference patterns\n- \ud83d\udcd0 Customizable image dimensions\n\n## Installation\n\n```bash\npip install light-captcha\n```\n\n## Quick Start\n\n```python\nfrom light_captcha import CaptchaGenerator\n\n# Create generator instance\ngenerator = CaptchaGenerator()\n\n# Generate English CAPTCHA\nimage, number = generator.generate('english')\nimage.save('captcha_english.png')\nprint(f\"Generated number: {number}\")\n\n# Generate Persian CAPTCHA\nimage, number = generator.generate('persian')\nimage.save('captcha_persian.png')\nprint(f\"Generated number: {number}\")\n```\n\n## Usage Examples\n\n### Custom Dimensions\n\n```python\n# Generate with custom size\nimage, number = generator.generate('english', width=300, height=100)\n```\n\n### Custom Colors\n\n```python\n# Generate with custom colors\nbg_color = (240, 248, 255)  # Light blue background\ntext_color = (25, 25, 112)   # Navy text\nimage, number = generator.generate(\n    'english', \n    bg_color=bg_color, \n    text_color=text_color\n)\n```\n\n### Batch Generation\n\n```python\ngenerator = CaptchaGenerator()\n\n# Generate multiple CAPTCHAs\nfor i in range(10):\n    image, number = generator.generate('persian')\n    image.save(f'captcha_{i}.png')\n    print(f\"CAPTCHA {i}: {number}\")\n```\n\n## API Reference\n\n### CaptchaGenerator\n\n#### `generate(language, width=250, height=80, bg_color=None, text_color=None)`\n\nGenerate a CAPTCHA image.\n\n**Parameters:**\n- `language` (str): `'english'` or `'persian'`\n- `width` (int): Image width in pixels (default: 250)\n- `height` (int): Image height in pixels (default: 80)  \n- `bg_color` (tuple, optional): RGB background color\n- `text_color` (tuple, optional): RGB text color\n\n**Returns:**\n- `tuple`: (PIL Image object, 6-digit string)\n\n**Raises:**\n- `ValueError`: If language is not 'english' or 'persian'\n- `FileNotFoundError`: If required font file is missing\n\n## Security Features\n\n- **Random Skewing**: Each digit rotated -15\u00b0 to +15\u00b0\n- **Size Variation**: Random scaling 0.8x to 1.2x per digit\n- **Wave Distortion**: Sinusoidal distortion across the image\n- **Noise Patterns**: Curved lines and random dots\n- **Color Randomization**: Multiple predefined color schemes\n- **Millisecond Seeding**: High-precision random generation\n\n## Requirements\n\n- Python 3.7+\n- Pillow >= 8.0.0\n\n## License\n\nMIT License - see LICENSE file for details.\n\n## Contributing\n\nIssues and pull requests are welcome on [GitHub](https://github.com/COD332/light-captcha).\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A lightweight CAPTCHA generator for Persian and English digits",
    "version": "0.0.1",
    "project_urls": {
        "Homepage": "https://github.com/COD332/light-captcha",
        "Issues": "https://github.com/COD332/light-captcha/issues",
        "Repository": "https://github.com/COD332/light-captcha"
    },
    "split_keywords": [
        "captcha",
        " persian",
        " english",
        " security",
        " image",
        " generation"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "66f86c4e095fcdecccfade7d9fd74f3621662bc641908a54fbee4c7d44384c2a",
                "md5": "ccbfcc8ce27b73bdd4da57fc97ec9be0",
                "sha256": "87ae560b6576b71f7493605b6ad93edc9b75a1a3b15ab400d72e1e490cd41b8e"
            },
            "downloads": -1,
            "filename": "light_captcha-0.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ccbfcc8ce27b73bdd4da57fc97ec9be0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 128543,
            "upload_time": "2025-07-20T20:52:27",
            "upload_time_iso_8601": "2025-07-20T20:52:27.331086Z",
            "url": "https://files.pythonhosted.org/packages/66/f8/6c4e095fcdecccfade7d9fd74f3621662bc641908a54fbee4c7d44384c2a/light_captcha-0.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "963c7f33b2575c307ebd4221f62759227a16feab40181994a2ec01d15ef6a7b3",
                "md5": "ed596e1a65af6cd1a4c8cba584c690ee",
                "sha256": "46b8f608db8db3e15bd9f8fa88a3458eb1f7c6155518fb76429f5aab981e461d"
            },
            "downloads": -1,
            "filename": "light_captcha-0.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "ed596e1a65af6cd1a4c8cba584c690ee",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 130237,
            "upload_time": "2025-07-20T20:52:29",
            "upload_time_iso_8601": "2025-07-20T20:52:29.400540Z",
            "url": "https://files.pythonhosted.org/packages/96/3c/7f33b2575c307ebd4221f62759227a16feab40181994a2ec01d15ef6a7b3/light_captcha-0.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-20 20:52:29",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "COD332",
    "github_project": "light-captcha",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "light-captcha"
}
        
Elapsed time: 0.42086s