reubendb wrote, On 16/12/07 13:54:
Hello,
I'm writing a C program that needs to calculate sha1sum of files on
Linux. Is it better to do this by using the already available
sha1sum(1) by using system call, or to use a library that provides
sha1sum implementation ? If the latter, can anyone give me pointer
where to I find such library ? (I tried Google but haven't found
anything).
I believe in as much as possible using library rather than using the
system function to call an external program. Either way is non-portable
(system is part of standard C but the programs you invoke through it are
not).
You can write a sha implementation yourself in standard C, but
personally I would use a well known and maintained library for anything
cryptographic, after all why risk me introducing bugs when I can use
something written (or peer reviewed) by experts?
If you do want to write it yourself hen google for "sha1 rfc" to get the
definition and post your attempt here. Otherwise any decent
cryptographic library should include sha1, I know openssl does for
instance. However, the cryptographic libraries are off topic here.
--
Flash Gordon