Hello .. I 'm doing sha1 program.
I don't know why this source result show below errors.

sha3.cpp:11: error: invalid conversion from ‘unsigned char*’ to ‘const char*’
sha3.cpp:11: error: initializing argument 1 of ‘size_t strlen(const char*)’

Thanks you.

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

int main()
{
    int i;

    unsigned char ibuf[] = "Hello, World!";
    unsigned char obuf[20];
    SHA1(ibuf, strlen(ibuf), obuf);

    for (i = 0; i < 20; i++) {
        printf("%02x ", obuf[i]);
    }
    printf("\n");

    return 0;
}

Recommended Answers

All 2 Replies

begone with ye' C code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.