【发布时间】:2016-08-19 04:01:33
【问题描述】:
我需要将Offset 中的int 添加到Code 中的每个数字中
这就是我如何制作Offset
num1 = (randint(33,126))
num2 = (randint(33,126))
num3 = (randint(33,126))
num4 = (randint(33,126))
num5 = (randint(33,126))
num6 = (randint(33,126))
num7 = (randint(33,126))
num8 = (randint(33,126))
key1 = chr(num1)
key2 = chr(num2)
key3 = chr(num3)
key4 = chr(num4)
key5 = chr(num5)
key6 = chr(num6)
key7 = chr(num7)
key8 = chr(num8)
characterkey = (key1 + key2 + key3 + key4 + key5 + key6 + key7 + key8)
Label(window2, text = characterkey, font = font, bg = "Dim grey", fg = "cyan").place(x = 130, y = 300)
offset = int(num1+num2+num3+num4+num5+num6+num7+num8)
offset = int(offset/8)
offset = int(offset - 32)
print(offset)
我在这里将一个文本文件转换成它的 ASCII 码
Code =" ".join(str(ord(char))for char in readFile)
但是我需要将偏移量添加到代码中的每个转换后的 Ascii 代码中,并且在添加偏移量之后,如果它等于 126 以上,它将减去 94
【问题讨论】:
-
您能否请为变量使用小写名称(参见PEP 8)?
标签: python-3.x encryption int ascii public-key-encryption