1
This commit is contained in:
@@ -0,0 +1,99 @@
|
||||
# 包含所有大小写字母、数字和常见可见特殊字符
|
||||
all_visible_characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()-_=+[]{}|;:,.<>?/~`\"'\\"
|
||||
# 包含所有大小写字母和数字
|
||||
alphanumeric_characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
|
||||
# 包含所有数字
|
||||
digit_characters = "0123456789"
|
||||
# 包含常见可见特殊字符(不包括空格)
|
||||
special_characters = "!@#$%^&*()-_=+[]{}|;:,.<>?/~`\"'\\"
|
||||
# 包含26个大写字母
|
||||
uppercase_only = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
# 包含26个小写字母
|
||||
lowercase_only = "abcdefghijklmnopqrstuvwxyz"
|
||||
# 包含26个小写字母和0-9 数字
|
||||
lowercase_digits = "abcdefghijklmnopqrstuvwxyz0123456789"
|
||||
# 包含26个大写字母和0-9 数字
|
||||
uppercase_digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
||||
|
||||
import secrets
|
||||
|
||||
|
||||
def get_all_visible_characters_code_8():
|
||||
code = ''.join(secrets.choice(all_visible_characters) for _ in range(8))
|
||||
|
||||
while(code[0] == '0'):
|
||||
first_digit = secrets.choice(all_visible_characters) # 1-9
|
||||
code = first_digit + code[1:]
|
||||
|
||||
return code
|
||||
|
||||
def get_all_visible_characters_code_6():
|
||||
|
||||
code = ''.join(secrets.choice(all_visible_characters) for _ in range(6))
|
||||
|
||||
while(code[0] == '0'):
|
||||
first_digit = secrets.choice(all_visible_characters) # 1-9
|
||||
code = first_digit + code[1:]
|
||||
|
||||
return code
|
||||
|
||||
def get_all_visible_characters_code(length):
|
||||
code = ''.join(secrets.choice(all_visible_characters) for _ in range(length))
|
||||
|
||||
while(code[0] == '0'):
|
||||
first_digit = secrets.choice(all_visible_characters) # 1-9
|
||||
code = first_digit + code[1:]
|
||||
|
||||
return code
|
||||
|
||||
def get_alphanumeric_characters_code(length):
|
||||
code = ''.join(secrets.choice(alphanumeric_characters) for _ in range(length))
|
||||
|
||||
while(code[0] == '0'):
|
||||
first_digit = secrets.choice(alphanumeric_characters) # 1-9
|
||||
code = first_digit + code[1:]
|
||||
|
||||
return code
|
||||
|
||||
def get_alphanumeric_characters_code_6():
|
||||
code = ''.join(secrets.choice(alphanumeric_characters) for _ in range(6))
|
||||
|
||||
while(code[0] == '0'):
|
||||
first_digit = secrets.choice(alphanumeric_characters) # 1-9
|
||||
code = first_digit + code[1:]
|
||||
|
||||
return code
|
||||
|
||||
def get_alphanumeric_characters_code_8():
|
||||
code = ''.join(secrets.choice(alphanumeric_characters) for _ in range(8))
|
||||
|
||||
while(code[0] == '0'):
|
||||
first_digit = secrets.choice(alphanumeric_characters) # 1-9
|
||||
code = first_digit + code[1:]
|
||||
|
||||
return code
|
||||
|
||||
def get_digit_characters_code(length):
|
||||
code = ''.join(secrets.choice(digit_characters) for _ in range(length))
|
||||
while(code[0] == '0'):
|
||||
first_digit = secrets.choice(digit_characters)
|
||||
code = first_digit + code[1:]
|
||||
|
||||
return code
|
||||
|
||||
def get_digit_characters_code_6():
|
||||
code = ''.join(secrets.choice(digit_characters) for _ in range(6))
|
||||
|
||||
while(code[0] == '0'):
|
||||
first_digit = secrets.choice(digit_characters)
|
||||
code = first_digit + code[1:]
|
||||
|
||||
return code
|
||||
|
||||
def get_digit_characters_code_8():
|
||||
code = ''.join(secrets.choice(digit_characters) for _ in range(8))
|
||||
while(code[0] == '0'):
|
||||
first_digit = secrets.choice(digit_characters)
|
||||
code = first_digit + code[1:]
|
||||
|
||||
return code
|
||||
Reference in New Issue
Block a user