calculating sha1sum

R

reubendb

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).

Thank you.
RDB
 
F

Flash Gordon

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.
 
T

Tor Rustad

reubendb said:
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).

It is better to use a library for this. Almost every crypt library on
the planet, comes with SHA-1 module, so it shouldn't be hard to find at all.

FYI, a search for "sha1.c" gave me ca. 75.000 google hits!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top