Hash-like Functions

72 Views Asked by At

Are there any cryptographically secure hash functions that can be given a array of strings to hash, and will always calculate the same output no matter what order the array elements are in?

I realize that one could merge the array elements into one string and hash that, but I'm asking specifically about functions that are order-independent (like bloom filters) but cryptographically secure (unlike bloom filters)

2

There are 2 best solutions below

0
Lev Knoblock On BEST ANSWER

After asking the same question on the Cryptography StackExchange, I was referred to this question which described Multiset Hash Functions, specifically the MSet-Mu-Hash and MSet-VAdd-Hash functions: https://crypto.stackexchange.com/questions/54544/how-to-to-calculate-the-hash-of-an-unordered-set

3
user2357112 On

Sort the array, apply whatever your favorite encoding is to convert the array into one string, and apply a standard cryptographic hash.