"SHA1" is deprecated: Deprecated first in OS X 10.7?

So I was trying to compile the code with a function SHA1

. I have included the following header:

#include <openssl/sha.h>

      

And I got the following error when compiling:

test.c:9:5: error: 'SHA1' is deprecated: first deprecated in OS X 10.7
  [-Werror,-Wdeprecated-declarations]
SHA1(msg, strlen(msg), hs);
^

      

But the man pages still have descriptions for this function.

Can anyone suggest any other header for a similar function (MD5 or SHA1)?

PS - also do I need to link any libraries when compiling with gcc?

+1


source to share


2 answers


You can still use it. Deprecated does not mean that it is not available. This is a recommendation to use a different hashing algorithm. You need to link to libcrypto - add -lcrypto

to the libraries you need to link to.

If you are using more openssl you will also need to set the link in libssl using -lssl

.



so, for example, if your test code is test.c, you would do:

gcc -o test test.c -lcrypto -lssl

      

+2


source


Apple is deprecated from OpenSSL, but don't worry, OpenSSL is a huge project and isn't going away anytime soon.

You can turn off the deprecated error by adding -Wno-error=deprecated-declarations

to your command line. This will contain warnings (which is useful because it can help you catch other deprecated declarations) without throwing errors.



There's some discussion as to why this is happening in this post: Why is Apple rejecting OpenSSL on macOS 10.7 (Lion)?

+1


source







All Articles