Skip to content

Commit

Permalink
Mimic MessageDigest.isEqual implementation for hashes-equal?
Browse files Browse the repository at this point in the history
  • Loading branch information
skinkade committed Nov 15, 2021
1 parent 5473a13 commit d7c2a95
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/uniformity/hash.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,10 @@
[hash1 hash2]
(if (not= (count hash1) (count hash2))
false
(reduce (fn [equals idx]
(and (= (get hash1 idx)
(get hash2 idx))
equals))
true
(range (count hash1)))))
(= 0
(reduce (fn [equals idx]
(bit-or equals
(bit-xor (int (get hash1 idx))
(int (get hash2 idx)))))
0
(range (count hash1))))))

0 comments on commit d7c2a95

Please sign in to comment.