我一直在努力测试相同的加密文件是否相同而不解密。我有一个提供给我的测试文件,其中包含正常数据和另一个加密版本。我需要检查通过 api 并对其进行加密的测试文件(未加密)是否与我得到的加密文件相同。这是用于检查这些文件的 python 脚本:
def compare_binaries(self,f1, f2):
'''
Using ittertools zip_longest to check each lines of both files
f1 - binary file of source file
f2- binary file of target file
Returns True if all lines are same else False if any line is not same
'''
for line1, line2 in zip_longest(f1, f2, fillvalue=None):
if line1 == line2:
continue
else:
return False
return True
这个过程可以检查加密文件是否相同,还是有更好的选择?