我想写一个简单的加密应用程序,在这里我需要一个文件,并添加1到每个字节的文件。这样做的目的是破坏一个文件,使其无法读取,但我的代码似乎什么都不做,因为输出与输入完全相同。你知道吗
filepath = './wayne.txt'
file = open(filepath, mode='rb') #read binary
file_bytes = bytearray(file.read())
print('File bytes:\n', file_bytes)
#Start the encryption
for byte in file_bytes:
byte += 1
print('File bytes after encryption:\n', file_bytes)
非常接近-实例化第二个bytearray,然后将每个修改的字节添加到其中。初始bytearray中的字节未进行适当修改。你知道吗
相关问题 更多 >
编程相关推荐