我有一个名为plain.txt 的文件。在我的文件里面:
Hello Hello Hello Hello
我正在使用此命令对其进行加密:
openssl enc -aes-128-cbc -salt -k "Hello" -in plain.txt -out encrypted.bin
然后我打印这样的加密值:
buff = open("encrypted.bin")
cipher = buff.read()
buff.close()
print b64encode(cipher)
但它总是不同的价值。密码不应该总是相同的吗?我使用相同的文件和相同的密码来加密它。这些是我的终端输出:
Richard-Knops-MacBook-Pro:python_test richardknop$ openssl enc -aes-128-cbc -salt -k "Hello" -in plain.txt -out encrypted.bin
Richard-Knops-MacBook-Pro:python_test richardknop$ python test.py U2FsdGVkX1+AmoQiIkYAxIYanLr/kbjMfEJPPLfeE/wtyxScvAKzb7K38ZxoI097
Richard-Knops-MacBook-Pro:python_test richardknop$ openssl enc -aes-128-cbc -salt -k "Hello" -in plain.txt -out encrypted.bin
Richard-Knops-MacBook-Pro:python_test richardknop$ python test.py U2FsdGVkX19vPD+OoiK7iSgYJiPMxuKGNWWrLlfBS0c3yCJkuv7QIBGEo2Q86UsV
Richard-Knops-MacBook-Pro:python_test richardknop$ openssl enc -aes-128-cbc -salt -k "Hello" -in plain.txt -out encrypted.bin
Richard-Knops-MacBook-Pro:python_test richardknop$ python test.py U2FsdGVkX1+3I8EC7u3lrcVPyD/JV12NAecWvTPXGga0Nh2cwqLAtGCDhLK6MI9g
Richard-Knops-MacBook-Pro:python_test richardknop$