How to use OpenSSL's SHA256 functions

后端 未结 2 435
半阙折子戏
半阙折子戏 2020-11-27 07:11

I\'m writing a program to get myself acquainted with OpenSSL, libncurses, and UDP networking. I decided to work with OpenSSL\'s SHA256 to become familiar with industry encry

相关标签:
2条回答
  • 2020-11-27 07:33

    You make a very common beginners mistake... Putting the libraries you link with in the wrong place on the command line when you build.

    Dependencies are reversed on the command line, so something that depends on something else should actually be put before what it depends on on the command line.

    In your example, you have a source file main.cpp that depends on some set of libraries, then the source file should be before the libraries it depend on:

    $ g++ -o main main.cpp -lssl -lcrypto
    

    To be safe, always put libraries last, after any source or object files listed on the command line.

    0 讨论(0)
  • 2020-11-27 07:38

    This works fine on my system, but you might try:

    extern "C" {
    #include <openssl/sha.h>
    }
    

    which tells g++ that all the stuff in openssl/sha.h is declared as "C" functions.

    BTW, how old is your OpenSSL?

    0 讨论(0)
提交回复
热议问题