Skip to content

Commit 190ca3e

Browse files
committed
refactor: login captcha
1 parent c1ddec1 commit 190ca3e

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

apps/common/util/common.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,12 @@ def markdown_to_plain_text(md: str) -> str:
300300
return text
301301

302302

303-
CHAR_SET = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
303+
SAFE_CHAR_SET = (
304+
[chr(i) for i in range(65, 91) if chr(i) not in {'I', 'O'}] + # 大写字母 A-H, J-N, P-Z
305+
[chr(i) for i in range(97, 123) if chr(i) not in {'i', 'l', 'o'}] + # 小写字母 a-h, j-n, p-z
306+
[str(i) for i in range(10) if str(i) not in {'0', '1', '7'}] # 数字 2-6, 8-9
307+
)
304308

305309

306-
def get_random_chars(number=6):
307-
return "".join([CHAR_SET[random.randint(0, len(CHAR_SET) - 1)] for index in range(number)])
310+
def get_random_chars(number=4):
311+
return ''.join(random.choices(SAFE_CHAR_SET, k=number))

0 commit comments

Comments
 (0)