MD5File() always returns the same digest on my OBSD 3.7.. - BSD

This is a discussion on MD5File() always returns the same digest on my OBSD 3.7.. - BSD ; Can anybody help? char buf[128]; printf("%s\n", MD5File("somefile", buf)); Chaging the content of somefile won't change anything and it'll just return the same digest. I've tried on FreeBSD and there's nothing wrong with it. Weird enough?...

+ Reply to Thread
Results 1 to 2 of 2

Thread: MD5File() always returns the same digest on my OBSD 3.7..

  1. MD5File() always returns the same digest on my OBSD 3.7..

    Can anybody help?

    char buf[128];
    printf("%s\n", MD5File("somefile", buf));

    Chaging the content of somefile won't change anything and it'll just return
    the same digest.
    I've tried on FreeBSD and there's nothing wrong with it.

    Weird enough?




  2. Re: MD5File() always returns the same digest on my OBSD 3.7..

    On 2005-05-30, Gary wrote:
    > Can anybody help?
    >
    > char buf[128];
    > printf("%s\n", MD5File("somefile", buf));
    >
    > Chaging the content of somefile won't change anything and it'll just return
    > the same digest.
    > I've tried on FreeBSD and there's nothing wrong with it.
    >
    > Weird enough?


    neptune:tmp {167} echo a > a
    neptune:tmp {168} echo b > b
    neptune:tmp {169} ./md5test
    uscreens: d41d8cd98f00b204e9800998ecf8427e
    ssh-eoMMo25774: d41d8cd98f00b204e9800998ecf8427e
    md5test: 1f58b1959cf83b0abf35396a8f01a37b
    a: 60b725f10c9c85c70d97880dfe8191b3
    b: 3b5d5c3712955042212316173ccf37be
    neptune:tmp {170} md5 a
    MD5 (a) = 60b725f10c9c85c70d97880dfe8191b3
    neptune:tmp {171} md5 b
    MD5 (b) = 3b5d5c3712955042212316173ccf37be

    works for me, however directories are the same hash.

    program below:

    #include
    #include
    #include
    #include
    #include
    #include

    int
    main(void)
    {
    DIR *dp;
    struct dirent *de;

    u_char md5_sum[MD5_DIGEST_STRING_LENGTH];
    int i;

    dp = opendir(".");
    if (dp == NULL) {
    perror("opendir");
    exit(1);
    }

    while ((de = readdir(dp)) != NULL) {
    if (de->d_name[0] == '.')
    continue;

    if (MD5File(de->d_name, md5_sum) == NULL) {
    perror("md5file");
    exit(1);
    }
    printf("%s: ", de->d_name);
    printf("%s\n", md5_sum);

    }

    closedir(dp);
    }


+ Reply to Thread