imanhpr / miniCaptcha

Python Simple Image Captcha Generator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

miniCaptcha

miniCaptcha can generate simple captchas with random colors.

Installation

Use the package manager pip to install ICaptcha.

pip install minicaptcha

Usage

You can change default font and save path :

from minicaptcha.captcha import ICaptcha

captcha = ICaptcha(font='font_1.ttf',save_path='test/path/dir')

ICaptcha() default font is : Roboto-Medium.ttf

default save path is : current absolute path of icaptcha

simple generated image Captcha

from minicaptcha.captcha import ICaptcha

captcha = ICaptcha()
random_char = captcha.generate_character(chr_count=6)
captcha.write_image(random_char,show_test=True)

Result :

name_330G2T2z0WP81r6

simple mathematical expression image captcha

You can use icaptcha for generate mathematical expression

from minicaptcha.captcha import ICaptcha

captcha = ICaptcha()
math_exp = captcha.math_exp() # (str -> '19-11' , int -> 8)
captcha.write_image(math_exp[0],show_test=True)

Result:

name_9G50p1E9w7jr554

Example

from minicaptcha.captcha import ICaptcha

captcha = ICaptcha()
random_char = captcha.generate_character(chr_count=6)
captcha.write_image(random_char,show_test=True)
user_input = input('Enter captcha please : ')
if user_input.lower() == random_char.lower():
    print(True)
else :
    print(False)

Contributing

If you think you can improve these codes please send pull request and help me to improve myself at programing.

License

MIT License

Copyright (c) 2020 Iman Hosseini Pour

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

About

Python Simple Image Captcha Generator

License:MIT License


Languages

Language:Python 100.0%