find . -type f -print0 | sort -z | xargs -0 shasum -a 256 | shasum -a 256 | awk '{print $1}'
For example, we have the following directory.
test/
├── a
└── b
To generate directory hash, change into directory and run the cmd.
$▶ cd test/
$▶ find . -type f -print0 | sort -z | xargs -0 shasum -a 256 | shasum -a 256 | awk '{print $1}'
9c5811e2d31262e0370d79c08d8e62bb5acbfeb19735103c220a037e8e369587