{"name":"captcha: A Python Library for Audio and Image CAPTCHAs","description":"captcha is a Python library designed to generate both audio and image CAPTCHAs. It offers a straightforward way to integrate robust human verification into web applications, enhancing security and user experience. With customizable options for fonts, voices, and colors, it provides flexibility for various project needs.","github":"https://github.com/lepture/captcha","url":"https://osrepos.com/repo/lepture-captcha","source":"osrepos.com","sourceDescription":"This repository profile is provided by osrepos.com, an open source repository discovery platform.","repositoryProfile":"https://osrepos.com/repo/lepture-captcha","generatedFor":"open source discovery and AI-assisted research","markdown":"https://osrepos.com/repo/lepture-captcha.md","json":"https://osrepos.com/repo/lepture-captcha.json","topics":["captcha","python","security","web development","bot prevention","audio captcha","image captcha","library"],"keywords":["captcha","python","security","web development","bot prevention","audio captcha","image captcha","library"],"stars":null,"summary":"captcha is a Python library designed to generate both audio and image CAPTCHAs. It offers a straightforward way to integrate robust human verification into web applications, enhancing security and user experience. With customizable options for fonts, voices, and colors, it provides flexibility for various project needs.","content":"## Introduction\n\nThe `captcha` library by lepture is a powerful Python tool for generating both audio and image CAPTCHAs. It provides a simple yet effective solution for implementing human verification challenges, crucial for preventing spam and automated abuse on websites and applications. This library is written in Python and is widely used for its ease of integration and flexibility.\n\n## Installation\n\nInstalling `captcha` is straightforward using pip. Open your terminal or command prompt and run the following command:\n\nbash\npip install captcha\n\n\nThis will install the library and its dependencies, allowing you to start generating CAPTCHAs immediately.\n\n## Examples\n\nThe library separates audio and image CAPTCHA generation into distinct modules, making it easy to use. Here are examples demonstrating how to generate both types of CAPTCHAs and how to customize image colors.\n\n### Basic Usage:\n\npython\nfrom captcha.audio import AudioCaptcha\nfrom captcha.image import ImageCaptcha\n\naudio = AudioCaptcha(voicedir='/path/to/voices') # Optional: use your own voice data\nimage = ImageCaptcha(fonts=['/path/A.ttf', '/path/B.ttf']) # Optional: use your own font data\n\n# Generate audio CAPTCHA\ndata_audio = audio.generate('1234')\naudio.write('1234', 'out.wav')\n\n# Generate image CAPTCHA\ndata_image = image.generate('1234')\nimage.write('1234', 'out.png')\n\n\nWhile the library includes built-in voice and font data, it is recommended to use your own custom data for production environments.\n\n### Custom Colors for Image CAPTCHA:\n\nYou can easily customize the background and foreground colors of your image CAPTCHAs by specifying RGB tuples.\n\npython\nfrom captcha.image import ImageCaptcha\n\nimage = ImageCaptcha(fonts=['/path/A.ttf', '/path/B.ttf'])\n\n# Red text on a yellow background\nimage.write('1234', 'out.png', bg_color=(255, 255, 0), fg_color=(255, 0, 0))\n\n\n## Why Use\n\nThe `captcha` library stands out for its simplicity and effectiveness in generating both visual and auditory challenges. Its Pythonic interface makes it easy for developers to integrate robust CAPTCHA functionality into their projects. Whether you need to protect forms, prevent bot registrations, or secure sensitive actions, `captcha` offers a reliable and customizable solution. The ability to use custom fonts and voices also allows for greater brand consistency and accessibility.\n\n## Links\n\nFor more detailed information, documentation, and to contribute to the project, refer to the official links:\n\n*   [GitHub Repository](https://github.com/lepture/captcha)\n*   [Official Documentation](https://captcha.lepture.com/)","metrics":{"detailViews":3,"githubClicks":2},"dates":{"published":null,"modified":"2025-11-05T20:00:31.000Z"}}