MCPcopy Create free account
hub / github.com/JohnDoe1996/fastAPI-vue / create_code

Function create_code

backend/app/utils/captcha_code.py:32–40  ·  view source on GitHub ↗
(k: int, *, img_width: int = 100, img_height: int = 50, font_sizes:List[int] = None)

Source from the content-addressed store, hash-verified

30
31
32def create_code(k: int, *, img_width: int = 100, img_height: int = 50, font_sizes:List[int] = None):
33 if not font_sizes:
34 font_sizes = [35, 30, 33]
35 elif isinstance(font_sizes, int):
36 font_sizes = [font_sizes]
37 image = ImageCaptcha(width=img_width, height=img_height, font_sizes=font_sizes)
38 codes = ''.join(random.choices(WORDS, k=k))
39 captcha_img = image.generate(codes)
40 return captcha_img.read(), codes
41
42
43def create_base64_code(k: int, *, img_width: int = 100, img_height: int = 50, font_sizes:List[int] = None):

Callers 1

create_base64_codeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected