I want to use SHA1
function from openssl library for hashing a string, I have downloaded the library and installed it in /usr/include
, and here is my code:
#include <openssl/sha.h>
#include <string.h>
#include <stdio.h>
int main() {
unsigned char digest[SHA_DIGEST_LENGTH];
char string[] = "hello world";
SHA1((unsigned char*) &string, strlen(string), (unsigned char*) &digest);
}
It doesn't have any syntax error and it recognizes openssl/sha.h, but when I want to build the project in eclipse or build from the terminal, I get this error:
Hash.cpp:(.text+0x4a): undefined reference to `SHA1'
collect2: error: ld returned 1 exit status
Any help would be appreciated! :)