Re: Are there any ready to use MD5 C-function in Linux?

Discussion in 'C Programming' started by Abby, Aug 20, 2003.

  1. Abby

    Abby Guest

    (Tom Naxos) wrote in message news:<>...
    > (Abby) wrote in message news:<>...
    > > I'm doing C programming which require MD5 algorithm. I have a string
    > > which needed to be hashed using MD5, but I have no idea how to do it.
    > > I've read RFC 1321, but it's way over my head ... anybody know if
    > > there're any ready-to-use function or other easier way to achive this?
    > > Please let me know. Thank you so much.

    >
    > the sources of the openssl crypto library contain a nice md5 implementation in C.
    > And other crypto oder hash algorithms as well.
    >
    > http://www.openssl.org/source/


    I use the following code, but it doesn't work.

    #include <stdio.h>
    #include <string.h>
    #include <openssl/md5.h>

    int main(){

    char password[20] = "password";
    MD5_CTX context;
    int i;
    unsigned char digest[16];
    unsigned int len = strlen (password);

    MD5_Init(&context);
    MD5_Update (&context, password, len);
    MD5_Final(digest, &context);

    printf ("MD5(\"%s\") = ", password);
    for (i = 0; i < 16; i++) {
    printf ("%02x", digest);
    }
    printf ("\n");
    return 0;
    }


    When I compiled this code, it generate error said
    [Linker error] undefined reference to `_MD5_Init'
    [Linker error] undefined reference to `_MD5_Update'
    [Linker error] undefined reference to `_MD5_Final'

    I'm not sure if I'm doing the right way. Please recommend.
     
    Abby, Aug 20, 2003
    #1
    1. Advertising


  2. > When I compiled this code, it generate error said
    > [Linker error] undefined reference to `_MD5_Init'
    > [Linker error] undefined reference to `_MD5_Update'
    > [Linker error] undefined reference to `_MD5_Final'
    >
    > I'm not sure if I'm doing the right way. Please recommend.



    It's probably the way you are compiling that is not correct. You are
    probably not linking to the openssl library correctly...

    With gcc, I have so that I just need to do
    gcc ...... -lcrypto
    to link to the openssl library.

    --Anton
     
    Anton Stiglic, Aug 20, 2003
    #2
    1. Advertising

  3. Abby

    Derk Gwen Guest

    (Abby) wrote:

    # When I compiled this code, it generate error said
    # [Linker error] undefined reference to `_MD5_Init'
    # [Linker error] undefined reference to `_MD5_Update'
    # [Linker error] undefined reference to `_MD5_Final'

    http://derkgwen.250free.com/html/rsa-mdv.html

    has the entire RSA donated code available.

    --
    Derk Gwen http://derkgwen.250free.com/html/index.html
    You face forward, or you face the possibility of shock and damage.
     
    Derk Gwen, Aug 21, 2003
    #3
    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. John Latter
    Replies:
    11
    Views:
    630
    Mark Parnell
    Sep 11, 2003
  2. Mark Hamptons

    Any ready made 'Upload' tools?

    Mark Hamptons, Jul 29, 2004, in forum: HTML
    Replies:
    16
    Views:
    754
    Mark Hamptons
    Jul 31, 2004
  3. Replies:
    9
    Views:
    17,142
    John Salerno
    May 8, 2006
  4. Peter Woodsky

    create a md5 / md5 passwd with a salt

    Peter Woodsky, Nov 20, 2008, in forum: Ruby
    Replies:
    6
    Views:
    222
    Brian Candler
    Nov 21, 2008
  5. Chris Waugh
    Replies:
    0
    Views:
    188
    Chris Waugh
    Aug 11, 2013
Loading...

Share This Page