因此,几年前,我在麦当劳的礼品卡系统中发现了一个漏洞。基本点是通过组合大约15-20张卡片和它们的代码,我得到了一个点,第3和第7个字符是相同的,而其他字符是完全随机的
我可能在我所在地区(土耳其)举行的新可口可乐节上也发现了同样的事情。我只是想问,我如何开发一个带有随机模块的代码,它将通过检查特定的算法来随机创建代码,例如,让我们再次使用相同的第3和第7个字符
通过保留它们,随机生成8个编号/字母代码。我还认为使用while-True会更好地生成无限量的它们。最后,我将把它们添加到一个列表中。但是,我需要中间部分的帮助。
import random
import string
def randomStringDigits(stringLength=6):
lettersAndDigits = string.ascii_letters + string.digits
return ''.join(random.choice(lettersAndDigits) for i in range(stringLength))
print ("Generating a Random String including letters and digits")
while True:
print ("First Random String is ", randomStringDigits(8))
你快到了。我只是稍微调整了一下-您可以按原样进行调整:
我不确定这是否合法,但问题很简单
但我们真的需要知道,只是小写字母?大写
另外,如果您试图在这些位置使用相同的内容生成它们,您仍然会在同一点进行切片,并在末尾添加字符串
好的,这是符合您要求的工作版本
我不确定这样做是否真的很优雅,但我只是将随机字母保留在一个列表中,在它们各自的位置插入值,然后将列表元素连接到一个字符串中
相关问题 更多 >
编程相关推荐