【Python】【加密】反转密码
反转密码是最弱的一种加密方式,意思是把密码从后往前输出,比如:密码明文是“Emily”,那么反转后的加密密码即为“ylimE”
1 2 3 4 5 6 7 8 9 10 11 |
>>> plaintext = "Emily" >>> ciphertext = '' >>> >>> i = len(plaintext) - 1 >>> while i >= 0: ... ciphertext = ciphertext + plaintext[i] ... i = i - 1 ... >>> print(ciphertext) ylimE >>> |
解密也很容易,还是利用这个程序即可。传入加密后的,输出的则是明文
1 2 3 4 5 6 7 8 9 10 11 |
>>> plaintext = "ylimE" >>> ciphertext = '' >>> >>> i = len(plaintext) - 1 >>> while i >= 0: ... ciphertext = ciphertext + plaintext[i] ... i = i - 1 ... >>> print(ciphertext) Emily >>> |