OpenSSL库计算SHA1哈希值 C/C++

下面的C/C++代码实现利用OpenSSL计算SHA1哈希值

 #include 
 #include 
 #include 

int main()
{
    unsigned const char ibuf[] = "compute sha1";
    unsigned char obuf[20];

    SHA1(ibuf, strlen((const char * )ibuf), obuf);
    int i;

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

    }    
    printf("\n");
    return 0;
}
gcc -o example_sha example_sha.cpp -lssl -lcrypto 

你可能感兴趣的:(OpenSSL库计算SHA1哈希值 C/C++)