Home » Questions » Computers [ Ask a new question ]

Can you use OpenSSL to generate an md5 or sha hash on a directory of files?

Can you use OpenSSL to generate an md5 or sha hash on a directory of files?

I'm interested in storing an indicator of file / directory integrity between two archived copies of directories. It's around 1TB of data stored recursively on hard drives. Is there a way using OpenSSL to generate a single hash for all the files that can be used as a comparison between two copies of the data, or at a later point to verify the data has not changed?

Asked by: Guest | Views: 68
Total answers/comments: 2
Guest [Entry]

You could recursively generate all the hashes, concatenate the hashes into a single file, then generate a hash of that file.
Guest [Entry]

"Doing a md5 sum on the tar would never work unless all of the metadata (creation date, etc.) was identical as well, because tar stores that as part of its archive.

I would probably do an md5 sum of the contents of all of the files:

find folder1 -type f | sort | tr '\n' '\0' | xargs -0 cat | openssl md5
find folder2 -type f | sort | tr '\n' '\0' | xargs -0 cat | openssl md5"