Reputation: 3632
I hava a array of many strings. And I want to create one hash. First I hashed all strings of that array like here:
for (int i = 0; i < strings.length(); i++)
{
strings[i] = hash(strings[i]);
}
So now I have hashes at level 1. Like on picture below. Is there any algorithm for do the next steps? I do not want to making merkle tree.
Upvotes: 0
Views: 1992
Reputation: 121
I feel Arrays.hashCode(Object a[])
can be used.
Please have a look if Arrays.hashCode(Object a[])
helps.
String[] strings = {"Hello 1", "Hello 1", "Hello 1"};
int hasCode = Arrays.hashCode(strings);
System.out.println(hasCode);
Upvotes: 4
Reputation: 32535
If I were you, I would join all strings into one, and then hash that long string.
Eg.
StringJoiner j=new StringJoiner("");//Or any other separator
Arrays.asList(strings).forEach(j::add);
String finalHash=hash(j.toString());
Upvotes: 3