Skip to content

Commit f8dafc9

Browse files
committed
concatenate without separators and newlines
1 parent 2407142 commit f8dafc9

File tree

1 file changed

+3
-2
lines changed
  • dataintegrityfingerprint

1 file changed

+3
-2
lines changed

dataintegrityfingerprint/dif.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def file_hash_list(self):
104104
@property
105105
def checksums(self):
106106
rtn = ""
107-
for h, fl in self.file_hash_list:
107+
for h, fl in sorted(self.file_hash_list, key=lambda x: x[1]):
108108
rtn += u"{0}{1}{2}\n".format(h, self.CHECKSUM_FILENAME_SEPARATOR,
109109
fl)
110110
return rtn
@@ -116,7 +116,8 @@ def dif(self):
116116

117117
hasher = new_hash_instance(self._hash_algorithm,
118118
self.allow_non_cryptographic_algorithms)
119-
hasher.update(self.checksums.encode("utf-8"))
119+
concat = "".join(["".join(x) for x in self.file_hash_list])
120+
hasher.update(concat.encode("utf-8"))
120121
return hasher.checksum
121122

122123
def count_files(self):

0 commit comments

Comments
 (0)