You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
777 B
31 lines
777 B
'''
|
|
Author: SJ2050
|
|
Date: 2021-10-16 21:43:32
|
|
LastEditTime: 2021-10-16 23:25:21
|
|
Version: v0.0.1
|
|
Description: Solution for homework8.
|
|
Copyright © 2021 SJ2050
|
|
'''
|
|
import random
|
|
import string
|
|
|
|
def activationCode(count, length):
|
|
res = set()
|
|
base = string.ascii_letters + string.digits
|
|
|
|
while len(res) < count:
|
|
res.add(''.join(random.sample(base, length)))
|
|
|
|
return res
|
|
|
|
if __name__ == '__main__':
|
|
n = 200 # count
|
|
l = 11 # length of each code
|
|
|
|
res = activationCode(n, l)
|
|
print(f'生成的{n}个激活码如下: ')
|
|
for item in res:
|
|
print(item)
|
|
|
|
# 激活码是用来授予用户相关权限的凭证,一般由一组数字和字母组成,其组合非常多,随机性较强,且能保证唯一,难以被外部破解。
|