不推荐使用"SHA1":在OS X 10.7中首先不推荐使用? [英] 'SHA1' is deprecated: first deprecated in OS X 10.7?

查看:131
本文介绍了不推荐使用"SHA1":在OS X 10.7中首先不推荐使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我试图编译具有SHA1函数的代码..我包括以下头文件:

So I was trying to compile a code which has a SHA1 function .. I included following header:

#include <openssl/sha.h>

在编译时出现以下错误:

And I got the following error while 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 man pages still have the descriptions for that function.

有人可以为类似功能(MD5或SHA1)建议任何其他标题吗?

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

PS-使用gcc进行编译时,我还需要链接任何库吗?

PS - also do I need to link any libraries while compiling using gcc?

推荐答案

您仍然可以使用它.已弃用并不意味着不可用.建议使用其他哈希算法.您需要链接到libcrypto-将-lcrypto添加到要链接的库中.

You can still use it. Deprecated does not mean not available. It's a recommendation to use a different hashing algorithm. You need to link to libcrypto - add -lcrypto to libraries to link to.

如果您使用更多的openssl,则还需要使用-lssl在libssl中进行链接.

If you're using more of openssl, you'll also need to link in libssl, using -lssl.

例如,如果您的测试代码为test.c,则可以这样做:

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

gcc -o test test.c -lcrypto -lssl

这篇关于不推荐使用"SHA1":在OS X 10.7中首先不推荐使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆