calculating sha1sum

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • reubendb

    #1

    calculating sha1sum

    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
  • Flash Gordon

    #2
    Re: calculating sha1sum

    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

    Comment

    • Tor Rustad

      #3
      Re: calculating sha1sum

      reubendb wrote:
      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!

      --
      Tor <bwzcab@wvtqvm. vw | tr i-za-h a-z>

      Comment

      Working...