我一直在尝试用 Python 编写一个简单的加密程序,当我尝试在 Linux 上执行代码时,它没有打印任何东西。有人可以告诉我为什么吗?
#!/usr/bin/env python2
import binascii
def encrypt():
text = raw_input("Please input your information to encrypt: ")
for i in text:
#Convert text into a binary sequence
i = bin(int(binascii.hexlify(i),16))
key = raw_input("Please input your key for decryption: ")
for j in key:
#Convert key into a binary sequence
j = bin(int(binascii.hexlify(j),16))
#This is only here for developmental purposes
print key
print text
编辑 我做了一位用户所说的,但我的代码似乎仍然没有像我想要的那样将我的纯文本转换为二进制文件。
#!/usr/bin/env python2
def encrypt():
text = raw_input("Please input your information to encrypt: ")
for i in text:
#Convert text into a binary sequence
i = bin(ord(i))
key = raw_input("Please input your key for decryption: ")
for j in key:
#Convert key into a binary sequence
j = bin(ord(j))
#This is only here for developmental purposes
print key
print text
encrypt()