# how to checksum on file/folder



## robert wild (May 26, 2017)

hi all,

how do you do a checksum of a file folder, i want to use sha512 as md5 is cracked

file -


```
sha512 path/to/file/file.tar
```

folder -


```
find -s path/to/folder -type f -exec sha512 {} \; | sha512
```

many thanks,

rob


----------



## ShelLuser (May 26, 2017)

Look into mtree(8).


----------



## Beastie (May 26, 2017)

Just a small note. I think you're confusing things here.

MD5 shouldn't be used for password hashing because it's unsalted and vulnerable to collision attacks. But it's still fine to use it for basic file integrity checks.
Being less computationally expensive than other algorithms such as SHA512 also makes it easier to crack (when used in a cryptographic system). And this is precisely the same reason it's more interesting for basic file integrity checks compared to the rest. You'll notice the difference when you want to generate checksums for thousands of files.


----------



## robert wild (May 26, 2017)

wow, wasnt expecting this, im getting all different checksum values

i think i will extract the tar and cross reference it with the source directory ie do on both

count number of files

size of directory

SHA512 (/vol/cha-work/_ARCHIVE/to_be_archived/audio/chad_r/2017-05-17/Even When I Fall - January 2017 Project.tar) = fa8a0c210f4616f27de9e66d5316bce62881baf794214ebecbf4a6fd576e09b274b278f0bef278315e12159083073975f02e5f03aff18682e5273722287df799

find -s /vol/cha-work/_ARCHIVE/to_be_archived/audio/chad_r/2017-05-17/Even\ When\ I\ Fall\ -\ January\ 2017\ Project/ -type f -exec sha512 {} \; | sha512
9bc5b7f9b2dcf68fc5b113cd359282e34876ad796c43e5b16701c9ff0cba3ba3b038af67db9f8a8dbadfa6d22ee3584f1c4ac840b710c5f422d7435f59c09c42

tar -cf - Even\ When\ I\ Fall\ -\ January\ 2017\ Project/ | sha512
ac81d3bc9dc843fd4c7d6e6bdbc477076437727044f291b5c162232efb8e8747c8b2d2bd82567e381ea235d158fba5d28e3c5eab9a60a86acba6b452960bb7da


----------

