I needed some code that produces SHA1 digests for a project I am working on. I hunted through the FreeBSD’s sha1(1) code and produced this minimal snippet. Hopefully this helps someone else in the future.
Compile and run as follows:
$ cc shatest.c -o shatest -lmd
$ printf "bismillah" | sha1
Thanks to FreeBSD for maintaining such clean code!