因此,我编写了一个程序,允许用户输入密码,并且密码被相当多的ord()字符移位:
encrypt=str(ord(letter)*x+x*7) #where x is a random number picked from an array然后将密码发送到一个文件:
passwrd=input("\nokay then " + name + " now enter your password which we will encrypt \nnew password:")
x=int(random.choice(randomNumber)) #The randomNumber array
myfile.write(str(x) + "\n")
pasw_file=open('secerateStuff.txt', 'w')
for letter in passwrd: #passwrd is the user input
encrypt=str(ord(letter)*x+x*7)
pasw_file.write(encrypt + "\n")
pasw_file.close()mypassword的一种可能编码是:
6 # In myfile
696 # In pasw_file
768
714
624
732
732
756
708
726
642我的问题是,您将如何将密码转换为ord()方法中的原始字符?(与chr()有关吗?)
谢谢你的回复!
发布于 2014-03-30 16:35:47
因为您用代码编写了salt,所以可以使用以下代码。
>>> passw = """6
696
768
714
624
732
732
756
708
726
642"""
>>> passw = map(int, passw.split())
>>> salt, passw = passw[0], passw[1:]
>>> salt
6
>>> passw
[696, 768, 714, 624, 732, 732, 756, 708, 726, 642]
>>> "".join([chr(elem/salt - 7) for elem in passw])
'mypassword'在Python 3中,您可以完成以下操作,我认为这样做看起来要好得多。(谢谢J.F. Sebastian)
>>> salt, *passw = map(int, passw.split())https://stackoverflow.com/questions/22746563
复制相似问题