miniCaptcha can generate simple captchas with random colors.
Use the package manager pip to install ICaptcha.
pip install minicaptcha
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
from minicaptcha.captcha import ICaptcha
captcha = ICaptcha()
random_char = captcha.generate_character(chr_count=6)
captcha.write_image(random_char,show_test=True)
Result :
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:
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)
If you think you can improve these codes please send pull request and help me to improve myself at programing.
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.