How to create a SHA1 digest on a tree of objects?

Posted by Torok Balint on Stack Overflow See other posts from Stack Overflow or by Torok Balint
Published on 2010-05-27T14:15:14Z Indexed on 2010/05/27 14:21 UTC
Read the original article Hit count: 262

Filed under:
|

Let's say that I have a tree of objects of which every one have a string representation. I want to create a SHA1 digest on the whole tree.

The easiest way would be to recursively go over each node of the tree. For each node I would concatenate (as simple strings) the SHA1 digests of all the children, add the string representation of the given nod to this concatenated string, and do a SHA1 on it. This would be the SHA1 digest of the given node.

The question is will this digest be just as "good" as if I would have concatenated the string representation of the child nodes, and not the digests of the child nodes?

Thanks

© Stack Overflow or respective owner

Related posts about sha1

Related posts about digest