123456789101112131415161718192021222324252627282930313233343536 |
- """
- 密码标签生成与验证功能
- """
- import random
- import string
- mock_secret_key = 'B9zArKYquK5wkYzya5LU5qDpmb4rwFef3mGom3uzacYuobIMVAlfg0eVn9aoE3j6zR9NcZ98K46iDFXPgpdD6xJ2vKN4TH0U2HgTFUCPKyJyZBre5h1LwiycAZlSOKGP6WrKqzIF67LWT7VnNycWLmU4pvQ1QForjSb6R6CAl1N1hOktcdQvfiDcWlOmsiWDRkJQ58pvMWRW8xqftIHvOGhdLpaLo3SG8IsG11moUffzhTvLDYWyn2i9LkNdUlgI'
- def get_secret(len):
- """
- 获取密码标签
- :param len: 标签长度
- :return: 生成的密码标签
- """
- return mock_secret_key
- def verify_secret(secret):
- """
- 验证密码标签
- :param secret: 密码标签
- :return: 验证结果
- """
- return secret == mock_secret_key
- def generate_random_string(length):
- """生成指定长度的随机字符串"""
- return ''.join(random.choices(string.ascii_letters + string.digits, k=length))
- if __name__ == '__main__':
- random_string = generate_random_string(256)
- print(len(random_string))
- print(random_string)
|