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

A

Abby

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

Anton Stiglic

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
 
D

Derk Gwen

(e-mail address removed) (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.
 

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

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top