Search code examples
ccross-platformsha1

Using SHA1 in C


I am developing a tool in C which takes in a file as a input. I need to compute the SHA1 sum for the file. This tool needs to be platform compatible with Linux, Mac and windows. The files are huge in size ranging from 150MB to 2G. I need the tool to be able to compute the SHA at least as fast as the sha1sum Linux utility.

Any suggestions how I could go about incorporating SHA1? I am wary about using the openssl interface, since the clients for the tool would not necessary have openssl installed.


Solution

  • OpenSSL is the de facto standard in C. It needn't be installed since you can supply the library along with your program (or even statically compile it).

    OpenSSL is BSD-style licensed, so you can even use just their SHA1 code directly in your program (giving credit), though it may be tricky to decouple it from the library.