Skip to main content

common captcha for web server

Project description

common-captcha 验证码程序,包括简单验证码和滑块验证码,基于用户行为验证

Features

  • 简单验证码

  • 滑动拼图验证码

Introduction

Install with pip:

$ pip install common-captcha

Preview

滑块验证码

https://gitee.com/anji-plus/captcha/raw/master/images/%E6%BB%91%E5%8A%A8%E6%8B%BC%E5%9B%BE.gif

How To Use?

在此之前,你需要准备一个可用的redis

redis_url redis://xxxxxx:xxxxxx@xxxxx:xxx/11

Configuration

class SimpleCaptchaConfig:
""" 简单验证码配置 """

    simple_captcha_cache_key = "SimpleCaptcha"  # simple captcha redis cache key
    simple_captcha_cache_key_expire = 6000  # simple captcha redis cache key expired time


class BlockPuzzleCaptchaConfig:
""" 滑块验证码配置 """

    block_puzzle_captcha_cache_key = "BlockPuzzleCaptcha"   # block puzzle captcha redis cache key
    block_puzzle_captcha_cache_key_expire = 6000    # block puzzle captcha redis cache key expired time
    block_puzzle_captcha_check_offsetX = 10     # block puzzle captcha verify offset x
    background_image_root_path = "resource/defaultImages/jigsaw/original"   # block puzzle background images
    template_image_root_path = "resource/defaultImages/jigsaw/slidingBlock"  # block puzzle template images
    pic_click_root_path = "resource/defaultImages/pic-click"    # block puzzle pic check images
    font_ttf_root_path = "resource/fonts/WenQuanZhengHei.ttf"   # block puzzle font.ttf
    font_water_text = "lei.wang"    # block puzzle captcha water text
    font_water_text_font_size = 22  # block puzzle captcha water text font size

当你需要针对定制化配置操作时,你需要重写对应的属性信息,并传入对应的验证码中:demo

from common_captcha.config import BlockPuzzleCaptchaConfig as _baseConfig

class BlockPuzzleCaptchaConfig(_baseConfig):
    font_water_text_font_size = 30
    font_water_text = "中国传媒大学"

简单验证码:

from common_captcha.strategy.simple_captcha import SimpleCaptcha

simple_captcha = SimpleCaptcha(redis_url="redis://xxxxxx:xxxxxx@xxxxx:xxx/11", configs=BlockPuzzleCaptchaConfig)
print(simple_captcha.get())
print(simple_captcha.verify({"token": "", "code": ""}))

滑块验证码:

from common_captcha.strategy.block_puzzle_captcha import BlockPuzzleCaptcha

block_captcha = BlockPuzzleCaptcha(redis_url="redis://xxxxxx:xxxxxx@xxxxx:xxx/11")
print(block_captcha.get())
print(block_captcha.verify(token="", point_json={"x": "", "y": ""}))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

common_captcha-1.0.3.tar.gz (8.4 MB view details)

Uploaded Source

Built Distribution

common_captcha-1.0.3-py2.py3-none-any.whl (8.4 MB view details)

Uploaded Python 2 Python 3

File details

Details for the file common_captcha-1.0.3.tar.gz.

File metadata

  • Download URL: common_captcha-1.0.3.tar.gz
  • Upload date:
  • Size: 8.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for common_captcha-1.0.3.tar.gz
Algorithm Hash digest
SHA256 f396d6db9e6b5756105ae49e165a8ad565ab224c95900412d68f70cb9139246d
MD5 ac944e953dba897884a72cf7153e6058
BLAKE2b-256 098ba4bdace824d3fb724103b41a38573393eb5666ab1affa1030e06bde4907b

See more details on using hashes here.

File details

Details for the file common_captcha-1.0.3-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for common_captcha-1.0.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 4f524da512db9b18e63d7ffb9af8f0f7f6ed782bf2bb28fd13f003af1ade5c32
MD5 ef2f99e8405067d7c196a6a8df9271c4
BLAKE2b-256 8d04c567f3e730c0dc86391bf3611fd3cebfb7df6624bceafa139b928062f999

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page