I was initially working on SHA 128 algorithms & #include <openssl/sha.h> was
what was needed.Now, I need to work on SHA 256, but <openssl/sha.h> does not
seem to work. I've also tried sha2.h & sha256.h to no avail. I've checked
the source code & the SHA 256 APIs are defined in the same header file as
SHA 128, ie openssl/sha.h

SHA 128

#include <stdio.h>
#include <string.h>
#include <openssl/sha.h>

main(int argc, char *argv[])
{
        printf("%d\n", SHA_DIGEST_LENGTH);
}

Output

[r...@bglr-ccm34 tmp]# gcc -lcrypto sha2.c
[r...@bglr-ccm34 tmp]# ./a.out
20

SHA256

#include <stdio.h>
#include <string.h>
#include <openssl/sha.h>

main(int argc, char *argv[])
{
        printf("%d\n", SHA256_DIGEST_LENGTH);
}

Output

[r...@bglr-ccm34 tmp]# gcc -lcrypto sha2.c
sha2.c: In function `main':
sha2.c:7: error: `SHA256_DIGEST_LENGTH' undeclared (first use in this
function)
sha2.c:7: error: (Each undeclared identifier is reported only once
sha2.c:7: error: for each function it appears in.)

Reply via email to