Skip to main content

Python生成验证码的框架

Project description

zdppy_captcha

python用于生成图片,声音等验证码的底层框架

安装

pip install zdppy-captcha

使用教程

显示图片验证码

# 生成图片验证码
import random
from zdppy_captcha.image import ImageCaptcha

# 生成随机字符串
code = random.sample('abcdefghijklmnopqrstuvwxyz1234567890', 4)  # 随机选取4个不重复字符串,返回一个列表

# 生成图片验证码对象
image = ImageCaptcha()

# 第一种使用方式:生成图片验证码
im = image.generate_image(code)
im.show()  # 可以直接展示图片

保存验证码图片

# 生成图片验证码
import random
from zdppy_captcha.image import ImageCaptcha

# 生成随机字符串
code = random.sample('abcdefghijklmnopqrstuvwxyz1234567890', 4)  # 随机选取4个不重复字符串,返回一个列表

# 生成图片验证码对象
image = ImageCaptcha()

# 第二种使用方式:生成图片验证码并保存
image.write(code, 'zdppy_captcha.jpg')

将验证码转换为bytesio

# 生成图片验证码
import random
from zdppy_captcha.image import ImageCaptcha

# 生成随机字符串
code = random.sample('abcdefghijklmnopqrstuvwxyz1234567890', 4)  # 随机选取4个不重复字符串,返回一个列表

# 生成图片验证码对象
image = ImageCaptcha()

# 第三种使用方式:生成图片验证码BytesIO
data = image.generate(code)
print(data, type(data))

生成base64图片

import zdppy_captcha as captcha

# 获取验证码以及base64图片
code, img = captcha.get_base64(6)
print(code)
print(img)

版本历史

v0.1.0

  • 基本用法

v0.1.2

  • get_base64生成key,code和img

v0.1.3

  • 新增zdppy_api.get方法

v0.1.4

  • 支持zdppy低代码开发

v0.1.5

  • TODO: 让验证码的key只能使用1次,安全性更高

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

zdppy_captcha-0.1.5.tar.gz (105.3 kB view details)

Uploaded Source

Built Distribution

zdppy_captcha-0.1.5-py3-none-any.whl (107.8 kB view details)

Uploaded Python 3

File details

Details for the file zdppy_captcha-0.1.5.tar.gz.

File metadata

  • Download URL: zdppy_captcha-0.1.5.tar.gz
  • Upload date:
  • Size: 105.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.8.19 Darwin/22.6.0

File hashes

Hashes for zdppy_captcha-0.1.5.tar.gz
Algorithm Hash digest
SHA256 a9b8f8eaa7208786d41478a26567a3bad46abad4ca9459d917478741d90261d6
MD5 e0a4e065e9cacb2978d4e89fa48e5566
BLAKE2b-256 c62ea1143f13d9b3d397f1d6f3abe67ef6fff7a1d3405bd87fbcb8840bb31faf

See more details on using hashes here.

File details

Details for the file zdppy_captcha-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: zdppy_captcha-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 107.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.8.19 Darwin/22.6.0

File hashes

Hashes for zdppy_captcha-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 7d6174721c2b8003e79598eb39c5de960c08d2d90951977c46c3bb072cf05d6b
MD5 28dbc59b7aa7f660067b0f9e00cdb25b
BLAKE2b-256 39e073d8d7bd1dae584f2c6af6b4f2d6532b71c2b55e5385932bb9ebfc0c6be3

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