123456789101112131415161718192021222324252627282930313233343536 |
- """
- 密码标签生成与验证功能
- """
- import random
- import string
- import secrets
- # 模拟256长度的十六进制字符串
- mock_secret_key = '921999081bdd6fe50d3a5700e714915c31458929647e1d115bf180024cb67f7b337824246b8f74b0eeff021d5631ea9a1ec118297d759d01165eeabe4ee5d02519118ecc7d4d6bef43af09b5956b0adf92adcf99186a05a2f160c3071345a7093bc0cb476f9313db3330471cd764ddfeccd22d3fa090ecdd98cc4c0c083173e6'
- mock_secret_key_50 = '6e887a550f5ba6a7733ec341f1692027936895ca4041a50828'
- mock_secret_key_20 = '08b9dc4ab8f22541588a'
- mock_secret_key_512 = '0ba32b797dba3243c46840b224986f60e00526e5dda92891812a449ae23f24ed0cc38d860bec0af7b5359dc795fd1b8c5e9d24a4da4a7091ce0ea25913c21c66239b5352f138dc22349f49e6a47509dc07a30702d26c86885a5470fc2c659428c098daeb69c809dbe48739ae152b7d728eedbb2a02c213803cdf1218c9006801b4f566ca385e3752d6a825052191d518113c29055308ed1b815a7da88997babcd44cfd812ac7f75ff9e380c507e26e997a5849710104bea371955641b68a4f01ba0eabf4d425df9d123c2b1ab357599f3eb9070028f4e7f6ae60d0c060dacbf2f21e058dfb9adb4004dc4ae8d0c72f8bcc4ce7f604cf8919c1108796ab4571a3'
- def get_secret(len):
- """
- 获取密码标签
- :param len: 标签长度
- :return: 生成的密码标签
- """
- return mock_secret_key_512
- def verify_secret(secret):
- """
- 验证密码标签
- :param secret: 密码标签
- :return: 验证结果
- """
- return secret == mock_secret_key_512
- def generate_random_string(length):
- """生成指定长度的随机字符串"""
- return ''.join(random.choices(string.ascii_letters + string.digits, k=length))
- def generate_hex_string(length):
- return ''.join(secrets.choice('0123456789abcdef') for _ in range(length))
|