Skip to main content

A useful verification code generation tool.

Project description

安装

pip install gvcode

例子

from gvcode import VFCode



if __name__ == '__main__':
    vc = VFCode(
        width=200,                       # 图片宽度
        height=80,                       # 图片高度
        fontsize=50,                     # 字体尺寸
        font_color_values = [
                '#ffffff',
                '#000000',
                '#3e3e3e',
                '#ff1107',
                '#1bff46',
                '#ffbf13',
                '#235aff'
            ],                           # 字体颜色值
        font_background_value='#ffffff', # 背景颜色值
        draw_dots=False,                 # 是否画干扰点
        dots_width=1,                    # 干扰点宽度
        draw_lines=True,                 # 是否画干扰线
        lines_width=3,                   # 干扰线宽度
        mask=False,                      # 是否使用磨砂效果
        font='arial.ttf'                 # 字体 内置可选字体 arial.ttf calibri.ttf simsun.ttc
    )

    # 自定义验证码
    # vc.generate('abcd')

    # 数字验证码(默认5位)
    # vc.generate_digit()
    # 数字验证码(自定义位数)
    # vc.generate_digit(4)

    # 字母验证码(默认5位)
    # vc.generate_alpha()
    # 字母验证码(自定义位数)
    # vc.generate_alpha(5)

    # 数字字母混合验证码(默认5位)
    # vc.generate_mix()
    # 数字字母混合验证码(自定义位数)
    # vc.generate_mix(6)

    # 数字运算验证码(默认加法)
    vc.generate_op()
    # 数字运算验证码(加法)
    # vc.generate_op('+')
    # 数字运算验证码(减法)
    # vc.generate_op('-')
    # 数字运算验证码(乘法)
    # vc.generate_op('x')

    # 图片字节码
    # print(vc.get_img_bytes())
    # 图片base64编码
    print(vc.get_img_base64())
    # 保存图片
    vc.save()

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

gvcode-1.0.3.tar.gz (10.8 MB view details)

Uploaded Source

Built Distribution

gvcode-1.0.3-py3-none-any.whl (10.9 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: gvcode-1.0.3.tar.gz
  • Upload date:
  • Size: 10.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.0

File hashes

Hashes for gvcode-1.0.3.tar.gz
Algorithm Hash digest
SHA256 62d87e08c766071ec2c6be86d82bf35fee7965b082f05054cf320dab21252830
MD5 575d054eda0915471178d17225c2ad34
BLAKE2b-256 bae9a8d71deb1d88f19b8c04caab88ceff129f4e57c2afcfd669842415e9d6db

See more details on using hashes here.

File details

Details for the file gvcode-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: gvcode-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 10.9 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.0

File hashes

Hashes for gvcode-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 1a92668114c2dc5cedd34ae7381c3c19b53b09938ea9bc358a16b6ebcf4c3766
MD5 fe961e62a80e8dbc97c2c8a9519d341d
BLAKE2b-256 78ecf935eb2de4a9b6eb990c95311b8ce8b4898f35e3e2fedaca12e3e57c3e6c

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