Opensource software for computing checksum?

Discussion in 'C Programming' started by Zahid Faizal, Dec 20, 2005.

  1. Zahid Faizal

    Zahid Faizal Guest

    Kindly suggest a good opensource package (in C or C++) that can compute
    the checksum of a file. SHA2 would be preferable, but SHA1/SHA0/MD5
    would be acceptable as well. We have cards with different processors,
    running different operating systems, and we would like a package that
    provides the checksum value consistently across different processor
    architectures and operating systems.

    Zahid
    Zahid Faizal, Dec 20, 2005
    #1
    1. Advertising

  2. "Zahid Faizal" <> writes:

    >Kindly suggest a good opensource package (in C or C++) that can compute
    >the checksum of a file. SHA2 would be preferable, but SHA1/SHA0/MD5
    >would be acceptable as well. We have cards with different processors,
    >running different operating systems, and we would like a package that
    >provides the checksum value consistently across different processor
    >architectures and operating systems.


    <OT>
    The OpenSSL libraries, http://www.openssl.org/,
    or a trivial Google search.
    </OT>

    --
    Chris.
    Chris McDonald, Dec 20, 2005
    #2
    1. Advertising

  3. Zahid Faizal

    Dave Guest

    Zahid Faizal wrote:
    > Kindly suggest a good opensource package (in C or C++) that can compute
    > the checksum of a file. SHA2 would be preferable, but SHA1/SHA0/MD5
    > would be acceptable as well. We have cards with different processors,
    > running different operating systems, and we would like a package that
    > provides the checksum value consistently across different processor
    > architectures and operating systems.
    >
    > Zahid
    >


    I wanted md5 myself yesterday and found it on the web. Can't recall
    where, but here is the code below. There are 3 files - I leave it as an
    excercise for you to find out where main.c ends and md5.c starts and
    where md5.c ends and md5.h starts!!



    sparrow /export/home/drkirkby % cat main.c md5.c md5.h
    /*

    Calculate or Check MD5 Signature of File or Command Line Argument

    by John Walker
    http://www.fourmilab.ch/

    This program is in the public domain.

    */

    #define VERSION "2.1 (2003-09-23)"

    #include <stdio.h>
    #include <ctype.h>
    #include <string.h>
    #ifdef _WIN32
    #include <fcntl.h>
    #include <io.h>
    #endif

    #include "md5.h"

    #define FALSE 0
    #define TRUE 1

    #define EOS '\0'

    /* Main program */

    int main(argc, argv)
    int argc; char *argv[];
    {
    int i, j, opt, cdata = FALSE, docheck = FALSE, showfile = TRUE, f = 0;
    unsigned int bp;
    char *cp, *clabel, *ifname, *hexfmt = "%02X";
    FILE *in = stdin, *out = stdout;
    unsigned char buffer[16384], signature[16], csig[16];
    struct MD5Context md5c;

    /* Build parameter quality control. Verify machine
    properties were properly set in md5.h and refuse
    to run if they're not correct. */

    #ifdef CHECK_HARDWARE_PROPERTIES
    /* Verify unit32 is, in fact, a 32 bit data type. */
    if (sizeof(uint32) != 4) {
    fprintf(stderr, "** Configuration error. Setting for uint32 in
    file md5.h\n");
    fprintf(stderr, " is incorrect. This must be a 32 bit data
    type, but it\n");
    fprintf(stderr, " is configured as a %d bit data type.\n",
    sizeof(uint32) * 8);
    return 2;
    }

    /* If HIGHFIRST is not defined, verify that this machine is,
    in fact, a little-endian architecture. */

    #ifndef HIGHFIRST
    { uint32 t = 0x12345678;

    if (*((char *) &t) != 0x78) {
    fprintf(stderr, "** Configuration error. Setting for
    HIGHFIRST in file md5.h\n");
    fprintf(stderr, " is incorrect. This symbol has not been
    defined, yet this\n");
    fprintf(stderr, " machine is a big-endian (most
    significant byte first in\n");
    fprintf(stderr, " memory) architecture. Please modify
    md5.h so HIGHFIRST is\n");
    fprintf(stderr, " defined when building for this
    machine.\n");
    return 2;
    }
    }
    #endif
    #endif

    /* Process command line options. */

    for (i = 1; i < argc; i++) {
    cp = argv;
    if (*cp == '-') {
    if (strlen(cp) == 1) {
    i++;
    break; /* - -- Mark end of options;
    balance are files */
    }
    opt = *(++cp);
    if (islower(opt)) {
    opt = toupper(opt);
    }

    switch (opt) {

    case 'C': /* -Csignature -- Check
    signature, set return code */
    docheck = TRUE;
    if (strlen(cp + 1) != 32) {
    docheck = FALSE;
    }
    memset(csig, 0, 16);
    clabel = cp + 1;
    for (j = 0; j < 16; j++) {
    if (isxdigit((int) clabel[0]) && isxdigit((int)
    clabel[1]) &&
    sscanf((cp + 1 + (j * 2)), hexfmt, &bp) == 1) {
    csig[j] = (unsigned char) bp;
    } else {
    docheck = FALSE;
    break;
    }
    clabel += 2;
    }
    if (!docheck) {
    fprintf(stderr, "Error in signature
    specification. Must be 32 hex digits.\n");
    return 2;
    }
    break;

    case 'D': /* -Dtext -- Compute signature
    of given text */
    MD5Init(&md5c);
    MD5Update(&md5c, (unsigned char *) (cp + 1),
    strlen(cp + 1));
    cdata = TRUE;
    f++; /* Mark no infile argument needed */
    break;

    case 'L': /* -L -- Use lower case letters
    as hex digits */
    hexfmt = "%02x";
    break;

    case 'N': /* -N -- Don't show file name
    after sum */
    showfile = FALSE;
    break;

    case 'O': /* -Ofname -- Write output to
    fname (- = stdout) */
    cp++;
    if (strcmp(cp, "-") != 0) {
    if (out != stdout) {
    fprintf(stderr, "Redundant output file
    specification.\n");
    return 2;
    }
    if ((out = fopen(cp, "w")) == NULL) {
    fprintf(stderr, "Cannot open output file
    %s\n", cp); return 2;
    }
    }
    break;

    case '?': /* -U, -? -H -- Print how to
    call information. */
    case 'H':
    case 'U':
    printf("\nMD5 -- Calculate MD5 signature of file. Call");
    printf("\n with md5 [ options ] [file ...]");
    printf("\n");
    printf("\n Options:");
    printf("\n -csig Check against sig, set exit status
    0 = OK"); printf("\n -dtext Compute signature of text
    argument");
    printf("\n -l Use lower case letters for
    hexadecimal digits");
    printf("\n -n Do not show file name after sum");
    printf("\n -ofname Write output to fname (- = stdout)");
    printf("\n -u Print this message");
    printf("\n -v Print version information");
    printf("\n");
    printf("\nby John Walker -- http://www.fourmilab.ch/");
    printf("\nVersion %s\n", VERSION);
    printf("\nThis program is in the public domain.\n");
    printf("\n");
    #ifdef CHECK_HARDWARE_PROPERTIES
    #ifdef HIGHFIRST
    { uint32 t = 0x12345678;

    if (*((char *) &t) == 0x78) {
    fprintf(stderr, "** Note. md5 is not optimally configured
    for use on this\n");
    fprintf(stderr, " machine. This is a little-endian
    (least significant byte\n");
    fprintf(stderr, " first in memory) architecture, yet md5
    has been built with the\n");
    fprintf(stderr, " symbol HIGHFIRST defined in md5.h,
    which includes code which\n");
    fprintf(stderr, " supports both big- and little-endian
    machines. Modifying\n");
    fprintf(stderr, " md5.h to undefine HIGHFIRST for this
    platform will make md5\n");
    fprintf(stderr, " run faster on it.\n");
    }
    }
    #endif
    #endif
    return 0;

    case 'V': /* -V -- Print version number */
    printf("%s\n", VERSION);
    return 0;
    }
    } else {
    break;
    }
    }

    if (cdata && (i < argc)) {
    fprintf(stderr, "Cannot specify both -d option and input file.\n");
    return 2;
    }

    if ((i >= argc) && (f == 0)) {
    f++;
    }

    for (; (f > 0) || (i < argc); i++) {
    if ((!cdata) && (f > 0)) {
    ifname = "-";
    } else {
    ifname = argv;
    }
    f = 0;

    if (!cdata) {

    /* If the data weren't supplied on the command line with
    the "-d" option, read it now from the input file. */

    if (strcmp(ifname, "-") != 0) {
    if ((in = fopen(ifname, "rb")) == NULL) {
    fprintf(stderr, "Cannot open input file %s\n", ifname);
    return 2;
    }
    } else {
    in = stdin;
    }
    #ifdef _WIN32

    /** Warning! On systems which distinguish text mode and
    binary I/O (MS-DOS, Macintosh, etc.) the modes in the open
    statement for "in" should have forced the input file into
    binary mode. But what if we're reading from standard
    input? Well, then we need to do a system-specific tweak
    to make sure it's in binary mode. While we're at it,
    let's set the mode to binary regardless of however fopen
    set it.

    The following code, conditional on _WIN32, sets binary
    mode using the method prescribed by Microsoft Visual C 7.0
    ("Monkey C"); this may require modification if you're
    using a different compiler or release of Monkey C. If
    you're porting this code to a different system which
    distinguishes text and binary files, you'll need to add
    the equivalent call for that system. */

    _setmode(_fileno(in), _O_BINARY);
    #endif

    MD5Init(&md5c);
    while ((j = (int) fread(buffer, 1, sizeof buffer, in)) > 0) {
    MD5Update(&md5c, buffer, (unsigned) j);
    }
    }
    MD5Final(signature, &md5c);

    if (docheck) {
    docheck = 0;
    for (j = 0; j < sizeof signature; j++) {
    if (signature[j] != csig[j]) {
    docheck = 1;
    break;
    }
    }
    if (i < (argc - 1)) {
    fprintf(stderr, "Only one file may be tested with the
    -c option.\n");
    return 2;
    }
    } else {
    for (j = 0; j < sizeof signature; j++) {
    fprintf(out, hexfmt, signature[j]);
    }
    if ((!cdata) && showfile) {
    fprintf(out, " %s", (in == stdin) ? "-" : ifname);
    }
    fprintf(out, "\n");
    }
    }

    return docheck;
    }
    /*
    * This code implements the MD5 message-digest algorithm.
    * The algorithm is due to Ron Rivest. This code was
    * written by Colin Plumb in 1993, no copyright is claimed.
    * This code is in the public domain; do with it what you wish.
    *
    * Equivalent code is available from RSA Data Security, Inc.
    * This code has been tested against that, and is equivalent,
    * except that you don't need to include two pages of legalese
    * with every copy.
    *
    * To compute the message digest of a chunk of bytes, declare an
    * MD5Context structure, pass it to MD5Init, call MD5Update as
    * needed on buffers full of bytes, and then call MD5Final, which
    * will fill a supplied 16-byte array with the digest.
    */

    /* Brutally hacked by John Walker back from ANSI C to K&R (no
    prototypes) to maintain the tradition that Netfone will compile
    with Sun's original "cc". */

    #include <memory.h> /* for memcpy() */
    #include "md5.h"

    #ifndef HIGHFIRST
    #define byteReverse(buf, len) /* Nothing */
    #else
    /*
    * Note: this code is harmless on little-endian machines.
    */
    void byteReverse(buf, longs)
    unsigned char *buf; unsigned longs;
    {
    uint32 t;
    do {
    t = (uint32) ((unsigned) buf[3] << 8 | buf[2]) << 16 |
    ((unsigned) buf[1] << 8 | buf[0]);
    *(uint32 *) buf = t;
    buf += 4;
    } while (--longs);
    }
    #endif

    /*
    * Start MD5 accumulation. Set bit count to 0 and buffer to mysterious
    * initialization constants.
    */
    void MD5Init(ctx)
    struct MD5Context *ctx;
    {
    ctx->buf[0] = 0x67452301;
    ctx->buf[1] = 0xefcdab89;
    ctx->buf[2] = 0x98badcfe;
    ctx->buf[3] = 0x10325476;

    ctx->bits[0] = 0;
    ctx->bits[1] = 0;
    }

    /*
    * Update context to reflect the concatenation of another buffer full
    * of bytes.
    */
    void MD5Update(ctx, buf, len)
    struct MD5Context *ctx; unsigned char *buf; unsigned len;
    {
    uint32 t;

    /* Update bitcount */

    t = ctx->bits[0];
    if ((ctx->bits[0] = t + ((uint32) len << 3)) < t)
    ctx->bits[1]++; /* Carry from low to high */
    ctx->bits[1] += len >> 29;

    t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */

    /* Handle any leading odd-sized chunks */

    if (t) {
    unsigned char *p = (unsigned char *) ctx->in + t;

    t = 64 - t;
    if (len < t) {
    memcpy(p, buf, len);
    return;
    }
    memcpy(p, buf, t);
    byteReverse(ctx->in, 16);
    MD5Transform(ctx->buf, (uint32 *) ctx->in);
    buf += t;
    len -= t;
    }
    /* Process data in 64-byte chunks */

    while (len >= 64) {
    memcpy(ctx->in, buf, 64);
    byteReverse(ctx->in, 16);
    MD5Transform(ctx->buf, (uint32 *) ctx->in);
    buf += 64;
    len -= 64;
    }

    /* Handle any remaining bytes of data. */

    memcpy(ctx->in, buf, len);
    }

    /*
    * Final wrapup - pad to 64-byte boundary with the bit pattern
    * 1 0* (64-bit count of bits processed, MSB-first)
    */
    void MD5Final(digest, ctx)
    unsigned char digest[16]; struct MD5Context *ctx;
    {
    unsigned count;
    unsigned char *p;

    /* Compute number of bytes mod 64 */
    count = (ctx->bits[0] >> 3) & 0x3F;

    /* Set the first char of padding to 0x80. This is safe since there is
    always at least one byte free */
    p = ctx->in + count;
    *p++ = 0x80;

    /* Bytes of padding needed to make 64 bytes */
    count = 64 - 1 - count;

    /* Pad out to 56 mod 64 */
    if (count < 8) {
    /* Two lots of padding: Pad the first block to 64 bytes */
    memset(p, 0, count);
    byteReverse(ctx->in, 16);
    MD5Transform(ctx->buf, (uint32 *) ctx->in);

    /* Now fill the next block with 56 bytes */
    memset(ctx->in, 0, 56);
    } else {
    /* Pad block to 56 bytes */
    memset(p, 0, count - 8);
    }
    byteReverse(ctx->in, 14);

    /* Append length in bits and transform */
    ((uint32 *) ctx->in)[14] = ctx->bits[0];
    ((uint32 *) ctx->in)[15] = ctx->bits[1];

    MD5Transform(ctx->buf, (uint32 *) ctx->in);
    byteReverse((unsigned char *) ctx->buf, 4);
    memcpy(digest, ctx->buf, 16);
    memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */
    }


    /* The four core functions - F1 is optimized somewhat */

    /* #define F1(x, y, z) (x & y | ~x & z) */
    #define F1(x, y, z) (z ^ (x & (y ^ z)))
    #define F2(x, y, z) F1(z, x, y)
    #define F3(x, y, z) (x ^ y ^ z)
    #define F4(x, y, z) (y ^ (x | ~z))

    /* This is the central step in the MD5 algorithm. */
    #define MD5STEP(f, w, x, y, z, data, s) \
    ( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x )

    /*
    * The core of the MD5 algorithm, this alters an existing MD5 hash to
    * reflect the addition of 16 longwords of new data. MD5Update blocks
    * the data and converts bytes into longwords for this routine.
    */
    void MD5Transform(buf, in)
    uint32 buf[4]; uint32 in[16];
    {
    register uint32 a, b, c, d;

    a = buf[0];
    b = buf[1];
    c = buf[2];
    d = buf[3];

    MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
    MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
    MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
    MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
    MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
    MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
    MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
    MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
    MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
    MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
    MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
    MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
    MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
    MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
    MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
    MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);

    MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
    MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
    MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
    MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
    MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
    MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
    MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
    MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
    MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
    MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
    MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
    MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
    MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
    MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
    MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
    MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);

    MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
    MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
    MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
    MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
    MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
    MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
    MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
    MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
    MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
    MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
    MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
    MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
    MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
    MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
    MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
    MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);

    MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
    MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
    MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
    MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
    MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
    MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
    MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
    MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
    MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
    MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
    MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
    MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
    MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
    MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
    MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
    MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);

    buf[0] += a;
    buf[1] += b;
    buf[2] += c;
    buf[3] += d;
    }
    #ifndef MD5_H
    #define MD5_H

    /* The following tests optimise behaviour on little-endian
    machines, where there is no need to reverse the byte order
    of 32 bit words in the MD5 computation. By default,
    HIGHFIRST is defined, which indicates we're running on a
    big-endian (most significant byte first) machine, on which
    the byteReverse function in md5.c must be invoked. However,
    byteReverse is coded in such a way that it is an identity
    function when run on a little-endian machine, so calling it
    on such a platform causes no harm apart from wasting time.
    If the platform is known to be little-endian, we speed
    things up by undefining HIGHFIRST, which defines
    byteReverse as a null macro. Doing things in this manner
    insures we work on new platforms regardless of their byte
    order. */

    #define HIGHFIRST

    #ifdef __i386__
    #undef HIGHFIRST
    #endif

    /* On machines where "long" is 64 bits, we need to declare
    uint32 as something guaranteed to be 32 bits. */

    #ifdef __alpha
    typedef unsigned int uint32;
    #else
    typedef unsigned long uint32;
    #endif

    struct MD5Context {
    uint32 buf[4];
    uint32 bits[2];
    unsigned char in[64];
    };

    extern void MD5Init();
    extern void MD5Update();
    extern void MD5Final();
    extern void MD5Transform();

    /*
    * This is needed to make RSAREF happy on some MS-DOS compilers.
    */
    typedef struct MD5Context MD5_CTX;

    /* Define CHECK_HARDWARE_PROPERTIES to have main,c verify
    byte order and uint32 settings. */
    #define CHECK_HARDWARE_PROPERTIES

    #endif /* !MD5_H */


    --
    Dave K

    http://www.southminster-branch-line.org.uk/

    Please note my email address changes periodically to avoid spam.
    It is always of the form: month-year@domain. Hitting reply will work
    for a couple of months only. Later set it manually. The month is
    always written in 3 letters (e.g. Jan, not January etc)
    Dave, Dec 20, 2005
    #3
  4. Dave <> writes:
    > Zahid Faizal wrote:
    >> Kindly suggest a good opensource package (in C or C++) that can compute
    >> the checksum of a file. SHA2 would be preferable, but SHA1/SHA0/MD5
    >> would be acceptable as well. We have cards with different processors,
    >> running different operating systems, and we would like a package that
    >> provides the checksum value consistently across different processor
    >> architectures and operating systems.
    >> Zahid
    >>

    >
    > I wanted md5 myself yesterday and found it on the web. Can't recall
    > where, but here is the code below. There are 3 files - I leave it as
    > an excercise for you to find out where main.c ends and md5.c starts
    > and where md5.c ends and md5.h starts!!
    >
    >
    >

    [607 lines deleted]

    If you found it on the web, posting a pointer would have been more
    appropriate than posting the actual code, especially since this isn't
    really a sources-wanted newsgroup.

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    We must do something. This is something. Therefore, we must do this.
    Keith Thompson, Dec 20, 2005
    #4
  5. Zahid Faizal

    Flash Gordon Guest

    Zahid Faizal wrote:
    > Kindly suggest a good opensource package (in C or C++) that can compute
    > the checksum of a file. SHA2 would be preferable, but SHA1/SHA0/MD5
    > would be acceptable as well. We have cards with different processors,
    > running different operating systems, and we would like a package that
    > provides the checksum value consistently across different processor
    > architectures and operating systems.


    Neither comp.lang.c not, I believe, comp.lang.c++ is an appropriate
    place for asking for source. comp.sources.d may be, but I've no idea
    about that. In comp.lang.c and comp.lang.c++ we discuss the C and C++
    languages respectively and when people post actual standard code we
    discuss that. Also, cross-posts between comp.lang.c and comp.lang.c++
    are rarely a good idea because the languages are different and what is a
    good solution in one is often either incorrect or at least a bad
    solution in the other.

    If you want to post an answer to the OP's request and don't know how to
    post it only to comp.sources.d (if that is an appropriate group) and you
    don't know how to remove the irrelevant groups then you can post it as a
    reply to this message as I've set follow ups. If you want to discuss
    what is topical in either comp.lang.c or comp.lang.c++ then please feel
    free to override the follow ups to specify the one group whose
    topicality you wish to discus.
    --
    Flash Gordon
    Living in interesting times.
    Although my email address says spam, it is real and I read it.
    Flash Gordon, Dec 20, 2005
    #5
  6. On Tue, 20 Dec 2005 20:34:37 GMT, Keith Thompson <>
    wrote:

    >Dave <> writes:
    >> Zahid Faizal wrote:
    >>> Kindly suggest a good opensource package (in C or C++) that can compute
    >>> the checksum of a file. SHA2 would be preferable, but SHA1/SHA0/MD5
    >>> would be acceptable as well. We have cards with different processors,
    >>> running different operating systems, and we would like a package that
    >>> provides the checksum value consistently across different processor
    >>> architectures and operating systems.
    >>> Zahid
    >>>

    >>
    >> I wanted md5 myself yesterday and found it on the web. Can't recall
    >> where, but here is the code below. There are 3 files - I leave it as
    >> an excercise for you to find out where main.c ends and md5.c starts
    >> and where md5.c ends and md5.h starts!!
    >>
    >>
    >>

    >[607 lines deleted]
    >
    >If you found it on the web, posting a pointer would have been more
    >appropriate than posting the actual code, especially since this isn't
    >really a sources-wanted newsgroup.


    Did you read the paragraph that you quoted? In particular, did you
    read:

    I wanted md5 myself yesterday and found it on the web. Can't
    recall where, but here is the code below.

    He didn't post a pointer to the source because he can't recall where
    he found the source. That said, in general your point is well taken.

    BTW the OP posted to three different groups.


    Richard Harter,
    http://home.tiac.net/~cri, http://www.varinoma.com
    I started out in life with nothing.
    I still have most of it left.
    Richard Harter, Dec 20, 2005
    #6
  7. Zahid Faizal

    Mark B Guest

    "Richard Harter" <> wrote in message
    news:...
    > On Tue, 20 Dec 2005 20:34:37 GMT, Keith Thompson <>
    > wrote:
    >
    >>Dave
    >><>
    >>writes:
    >>> Zahid Faizal wrote:
    >>>> Kindly suggest a good opensource package (in C or C++) that can compute
    >>>> the checksum of a file. SHA2 would be preferable, but SHA1/SHA0/MD5
    >>>> would be acceptable as well. We have cards with different processors,
    >>>> running different operating systems, and we would like a package that
    >>>> provides the checksum value consistently across different processor
    >>>> architectures and operating systems.
    >>>> Zahid
    >>>>
    >>>
    >>> I wanted md5 myself yesterday and found it on the web. Can't recall
    >>> where, but here is the code below. There are 3 files - I leave it as
    >>> an excercise for you to find out where main.c ends and md5.c starts
    >>> and where md5.c ends and md5.h starts!!
    >>>
    >>>
    >>>

    >>[607 lines deleted]
    >>
    >>If you found it on the web, posting a pointer would have been more
    >>appropriate than posting the actual code, especially since this isn't
    >>really a sources-wanted newsgroup.

    >
    > Did you read the paragraph that you quoted? In particular, did you
    > read:
    >
    > I wanted md5 myself yesterday and found it on the web. Can't
    > recall where, but here is the code below.
    >
    > He didn't post a pointer to the source because he can't recall where
    > he found the source. That said, in general your point is well taken.


    He found it once, a quick google search probably would have found it
    again. It's not as if the source is hidden... hell, it's a part of the RFC.
    OP should have been able to find it himself if he wasn't an idiot.

    > BTW the OP posted to three different groups.

    .... and the request was OT for at least 2 of those groups.
    That confirms my earlier suspicion... OP is an idiot.
    Mark B, Dec 20, 2005
    #7
  8. Zahid Faizal

    Dave Guest

    Mark B wrote:
    > "Richard Harter" <> wrote in message


    >>He didn't post a pointer to the source because he can't recall where
    >>he found the source. That said, in general your point is well taken.

    >
    >
    > He found it once, a quick google search probably would have found it
    > again. It's not as if the source is hidden... hell, it's a part of the RFC.
    > OP should have been able to find it himself if he wasn't an idiot.
    >


    When I wanted it yesterday I downloaded a few md5 related bits from
    several different sites. Some were .zip's, one or more .tar.gz'z. One
    that looked promising was only a library, with no main().

    I could have spent 5~10 minutes downloading several again until I found
    the site that had the code I downloaded yesterday. But it did not seem
    too much of a problem to just post the code inline.

    Normally I would have posted the link, but it would have taken me much
    more time to find the right link than it did to post the code inline.

    >>BTW the OP posted to three different groups.

    >
    > ... and the request was OT for at least 2 of those groups.
    > That confirms my earlier suspicion... OP is an idiot.


    I don't know what the charter of the C and C++ groups are, but it does
    not on the face of it seem too off-topic, given the OP wanted C or C++
    code. I've no idea what comp.sources.d is I must admit.

    Sorry if this offended you, but whilst I would agree the source is not
    hard to find (I found it yesterday), I thought I could help someone and
    did not want to waste unnecessary time in finding again, when it was
    easier to just copy and paste.
    --
    Dave K

    http://www.southminster-branch-line.org.uk/

    Please note my email address changes periodically to avoid spam.
    It is always of the form: month-year@domain. Hitting reply will work
    for a couple of months only. Later set it manually. The month is
    always written in 3 letters (e.g. Jan, not January etc)
    Dave, Dec 20, 2005
    #8
  9. <>
    wrote:
    >Zahid Faizal wrote:
    >> Kindly suggest a good opensource package (in C or C++) that can compute
    >> the checksum of a file. ....

    >...
    >I wanted md5 myself yesterday and found it on the web. Can't recall
    >where, but here is the code below.


    Could it be, by any chance, in John Walker's web site, as clearly
    written in lines 5 & 6 of the file ? ;)

    > by John Walker
    > http://www.fourmilab.ch/



    Roberto Waltman
    [ Please reply to the group,
    return address is invalid ]
    Roberto Waltman, Dec 20, 2005
    #9
  10. Dave
    <>
    writes:
    [...]
    > Sorry if this offended you, but whilst I would agree the source is not
    > hard to find (I found it yesterday), I thought I could help someone
    > and did not want to waste unnecessary time in finding again, when it
    > was easier to just copy and paste.


    It was easier for you. It would have been easier and more convenient
    for the rest of us if you had tracked down and posted a few links.

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    We must do something. This is something. Therefore, we must do this.
    Keith Thompson, Dec 21, 2005
    #10
  11. Zahid Faizal

    Dave Guest

    Keith Thompson wrote:
    > Dave
    > <>
    > writes:
    > [...]
    >
    >>Sorry if this offended you, but whilst I would agree the source is not
    >>hard to find (I found it yesterday), I thought I could help someone
    >>and did not want to waste unnecessary time in finding again, when it
    >>was easier to just copy and paste.

    >
    >
    > It was easier for you. It would have been easier and more convenient
    > for the rest of us if you had tracked down and posted a few links.


    It is not something I usually do - track down my previous posts in other
    newsgroups. But I don't regret it under the circumstances as I see them
    at the time - someone wanted a bit of code, I could not remember the
    source of it and I don't think it was excessive given todays' computers.

    I hope you agree it is pointless continuing discussing this, otherwise
    the bandwidth wasted in arguing about it will soon exceed the 17906
    bytes of C code in my original post - if it has not done so already.

    If you wish to reply feel free, but as far as I am concerned the matter
    is closed.

    --
    Dave K

    http://www.southminster-branch-line.org.uk/

    Please note my email address changes periodically to avoid spam.
    It is always of the form: month-year@domain. Hitting reply will work
    for a couple of months only. Later set it manually. The month is
    always written in 3 letters (e.g. Jan, not January etc)
    Dave, Dec 21, 2005
    #11
  12. Zahid Faizal

    Guest

    Roberto Waltman wrote:

    > Roberto Waltman
    > [ Please reply to the group,
    > return address is invalid ]


    This is off topic, but I am desparate!

    After doing a search, I found that you worked on the software for the
    Imagen 100. We have an Imagen 50 that is broken (the X-Y stage does not
    operate) and I need any help that I can find. I contacted the company
    that merged with Research Devices and they couldn't help me at all. If
    you can help me, or know someone who can, please contact me at:

    www.pnl.gov

    My contact info is in:

    http://www.emsl.pnl.gov/docs/annual_reports/2002/3_2_IDL.pdf

    Thanks,

    Tom Seim
    , Dec 24, 2005
    #12
  13. Zahid Faizal

    Flash Gordon Guest

    wrote:
    > Roberto Waltman wrote:
    >
    >> Roberto Waltman
    >> [ Please reply to the group,
    >> return address is invalid ]

    >
    > This is off topic, but I am desparate!


    1) Don't post a new message on a new topic as a reply on an existing
    thread.
    2) It doesn't matter that other people can't help you , that is your
    problem not ours.
    3) There are groups ending in .misc where a query on where to get help
    might be considered on-topic, they would certainly me more
    appropriate than any of the groups you've cross posted to.

    <snip>

    > you can help me, or know someone who can, please contact me at:
    >
    > www.pnl.gov


    4) Post here, get an answer here. Certainly don't expect people do
    download a pdf just to get your contact details!
    5) You have probably (or greatly reduced) your chances of getting help
    from the people who frequent these groups if you ever have a topical
    question to post.
    6) If you can't get help on things not topical here that is *your*
    problem, not ours.
    --
    Flash Gordon
    Living in interesting times.
    Although my email address says spam, it is real and I read it.
    Flash Gordon, Dec 24, 2005
    #13
  14. OT: imagen [was Re: Opensource software for computing checksum?]

    In article <-gordon.me.uk>,
    Flash Gordon <> wrote:
    > wrote:


    >> This is off topic, but I am desparate!


    >2) It doesn't matter that other people can't help you , that is your
    > problem not ours.


    >6) If you can't get help on things not topical here that is *your*
    > problem, not ours.


    Munificent displays of Christmas spirit always restore my faith in humanity.


    For the benefit of those who have not happened to have taken the time
    to research what the poster was asking for, and are wondering why Flash
    volunteered his assistance:

    The Research Devices Imagen that the poster was asking about is a
    device used to project a high resolution template onto a photosensitive
    crystal, in the photolithography stage of IC production.

    The poster seeing assistance works for the IDL (Instrument Development
    Laboratory) at the William R. Wiley Environmental Molecular Sciences
    Laboratory, which provides equipment and support for visiting
    researchers to investigate environmental (i.e., health and
    life-sciences) topics.

    The EMSL concentrates on biogeochemistry and subsurface science,
    interfacial chemistry and catalysis, structure/dynamics of biomolecules
    and biomolecular complexes, biochemical pathways, and aerosol chemistry.


    It is always a pleasure to see the level of concern for the
    environment and life in general shared by posters such as Flash,
    that lead them to offer such kind words and amazing assistance to
    those who have dedicated their professional lives to making the
    world a healthier place.
    --
    All is vanity. -- Ecclesiastes
    Walter Roberson, Dec 24, 2005
    #14
  15. Zahid Faizal

    Flash Gordon Guest

    Re: OT: imagen [was Re: Opensource software for computing checksum?]

    Walter Roberson wrote:
    > In article <-gordon.me.uk>,
    > Flash Gordon <> wrote:
    >> wrote:

    >
    >>> This is off topic, but I am desparate!

    ^^^^^^^^^^^^^^^^^

    >> 6) If you can't get help on things not topical here that is *your*
    >> problem, not ours.

    >
    > Munificent displays of Christmas spirit always restore my faith in humanity.


    What makes you think I am a Christian? If I'm not the Christmas is
    irrelevant to me.

    > For the benefit of those who have not happened to have taken the time
    > to research what the poster was asking for, and are wondering why Flash
    > volunteered his assistance:


    Most people know why, it's because the OP is only going to get decent
    advice somewhere it is appropriate.

    <snip irrelevant stuff about where the poster works>

    > It is always a pleasure to see the level of concern for the
    > environment and life in general shared by posters such as Flash,


    You have absolutely no idea whether I care for the environment or not. I
    somehow doubt that you have researched me well enough to know where I
    work or what I do for a living or what else I may do, so for all you
    know I could be spending the bulk of my time on such issues.

    You have obviously just decided to attack me for telling the OP that it
    is his/her problem to find where to get help, not ours, and have
    researched the OP. However, if you really cared about the OPs problem
    you would have researched the OPs problem and directed the OP to where
    s/he could get help instead of attacking me.
    --
    Flash Gordon
    Living in interesting times.
    Although my email address says spam, it is real and I read it.
    Flash Gordon, Dec 24, 2005
    #15
  16. Flash Gordon <> writes:
    > wrote:
    >> Roberto Waltman wrote:
    >>
    >>> Roberto Waltman
    >>> [ Please reply to the group,
    >>> return address is invalid ]

    >> This is off topic, but I am desparate!

    >
    > 1) Don't post a new message on a new topic as a reply on an existing
    > thread.
    > 2) It doesn't matter that other people can't help you , that is your
    > problem not ours.
    > 3) There are groups ending in .misc where a query on where to get help
    > might be considered on-topic, they would certainly me more
    > appropriate than any of the groups you've cross posted to.

    [snip]

    The OP was specifically trying to contact Roberto Waltman, who
    apparently has posted to these groups using an invalid e-mail address.
    This was arguably in appropriate, but the ensuing discussion hardly
    seems necessary. I suggest moving on.

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    We must do something. This is something. Therefore, we must do this.
    Keith Thompson, Dec 24, 2005
    #16
  17. Zahid Faizal

    BobR Guest

    Re: OT: imagen [was Re: Opensource software for computing checksum?] [OT]

    Flash Gordon wrote in message ...
    >Walter Roberson wrote:
    >> Munificent displays of Christmas spirit always restore my faith in

    humanity.
    >
    >What makes you think I am a Christian? If I'm not the Christmas is
    >irrelevant to me.


    In that case, "Merry Christmas".
    What has Christmas got to do with Christianity [1]? A TV program the other
    night showed a guy who uesd a computer model to trace back the 'star' event.
    He places Jesus' birthday at around April 16!
    Imagine that. Jesus avoided the IRS until he was almost a year old!! <G>

    Anyway, enjoy the holidays.
    What you believe is your own.

    [1] - it has become commercialism. ;-{
    --
    Bob R
    POVrookie
    BobR, Dec 24, 2005
    #17
  18. Zahid Faizal

    Guest

    On 24 Dec 2005 11:01:15 +0100, Flash Gordon <>
    wrote:
    > wrote:
    >> This is off topic, but I am desparate!

    >
    >1) Don't post a new message on a new topic as a reply on an existing
    > thread.
    >2) It doesn't matter that other people can't help you , that is your
    > problem not ours.


    Merry Christmas Asshole.

    >4) Post here, get an answer here. Certainly don't expect people do
    > download a pdf just to get your contact details!
    >5) You have probably (or greatly reduced) your chances of getting help
    > from the people who frequent these groups if you ever have a topical
    > question to post.
    >6) If you can't get help on things not topical here that is *your*
    > problem, not ours.


    It's pathologic idiots - yes I said idiot - like YOU that get people
    hurt or worse in serious situations. You have absolutely no
    situational awareness of your surroundings do you. Strict
    adherence to your sick little rules is all that matters, right.

    The OP acknowledged his MINOR transgression but said he was desperate.
    Despite being a sad little demigod in your own mind, it's not up to
    you to decide that, because
    people like you never get a clue as to when it is serious or not. If
    you don't already work for the government I'm sure you soon will be.
    Clueless wads like you always end up in the Complaint Dept. abusing
    taxpayers.

    I have news for you pal, there is more to life than this myopic ng.
    Can you fathom that? Oh, right, you have proven you can't. Why have I
    responded? I'm just sick of incompetent fools like you who fancy
    themselves bullies. And if you want to play big-dog territorial games
    I've been reading and posting in this ng since 1994. That's 77 dog
    years to you.

    "Bad things happen when good men do nothing."

    To everyone else: Merry Christmas dammit and a Happy New Year.
    , Dec 24, 2005
    #18
  19. Re: OT: imagen [was Re: Opensource software for computing checksum?] [OT]

    BobR said:

    > What has Christmas got to do with Christianity [1]?


    Plenty, for Christians. For everyone else, the chance (rarely taken, alas)
    to reflect on what Christmas /ought/ to have to do with Christianity.

    > A TV program the other
    > night showed a guy who uesd a computer model to trace back the 'star'
    > event. He places Jesus' birthday at around April 16!
    > Imagine that. Jesus avoided the IRS until he was almost a year old!! <G>


    Think of 25 December as Jesus' "official" birthday. If the Queen can have
    one, I don't see why He shouldn't get one too.

    I was trying to think of an ObTopic, but I'm struggling to come up with one
    that'll be relevant in all three groups. Even "hello world" would start an
    argument. :)

    --
    Richard Heathfield
    "Usenet is a strange place" - dmr 29/7/1999
    http://www.cpax.org.uk
    email: rjh at above domain (but drop the www, obviously)
    Richard Heathfield, Dec 24, 2005
    #19
  20. Zahid Faizal

    Guest

    Re: OT: imagen [was Re: Opensource software for computing checksum?]

    On Sat, 24 Dec 2005 20:42:03 +0000, Flash Gordon
    <> wrote:

    >Walter Roberson wrote:
    >> In article <-gordon.me.uk>,
    >> Flash Gordon <> wrote:
    >>> wrote:


    >What makes you think I am a Christian? If I'm not the Christmas is
    >irrelevant to me.


    >Most people know why, it's because the OP is only going to get decent
    >advice somewhere it is appropriate.


    I hear crickets and tumbleweeds at this "appropriate place."

    ><snip irrelevant stuff about where the poster works>


    Okay, now in jerk-off denial mode...

    >You have absolutely no idea whether I care for the environment or not. I
    >somehow doubt that you have researched me well enough to know where I
    >work or what I do for a living or what else I may do, so for all you
    >know I could be spending the bulk of my time on such issues.


    You work for the EPA then?

    >You have obviously just decided to attack me for telling the OP that it
    >is his/her problem to find where to get help, not ours, and have
    >researched the OP. However, if you really cared about the OPs problem
    >you would have researched the OPs problem and directed the OP to where
    >s/he could get help instead of attacking me.


    He never once "attacked" you.

    Flash-in-the-Pants has reached the pantheon of Usenet Kook Status.
    Congrats.

    You know many kooks end their sad existence during the holidays, look
    into it.

    Walking away muttering: My gawd, what an insufferable jerk. Phil
    Helmuth must be his brother....
    , Dec 24, 2005
    #20
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    323
  2. cracker
    Replies:
    2
    Views:
    378
    Sybren Stuvel
    May 19, 2006
  3. Zahid Faizal
    Replies:
    34
    Views:
    1,022
    Al Balmer
    Dec 27, 2005
  4. optical supercomputing

    Optical Computing: special issue - Natural Computing, Springer

    optical supercomputing, Dec 19, 2008, in forum: C Programming
    Replies:
    0
    Views:
    404
    optical supercomputing
    Dec 19, 2008
  5. optical supercomputing

    Optical Computing: special issue - Natural Computing, Springer

    optical supercomputing, Jan 16, 2009, in forum: C Programming
    Replies:
    0
    Views:
    438
    optical supercomputing
    Jan 16, 2009
Loading...

Share This Page