#include <algorithm>
#include <stdio.h>
#include <openssl/sha.h>
using namespace std;
int main()
{
unsigned char ibuf[] = "compute sha1";
unsigned char obuf[20];
SHA1(ibuf, strlen(ibuf), obuf);
int i;
for (i = 0; i < 20; i++) {
printf("%02x ", obuf[i]);
}
printf("\n");
}
g++ file.cpp -o file -l libssl
file.cpp: In function ‘int main()’:
file.cpp:29:27: error: invalid conversion from ‘unsigned char*’ to ‘const char*’ [-fpermissive]
/usr/include/string.h:399:15: error: initializing argument 1 of ‘size_t strlen(const char*)’ [-fpermissive]
不知道怎么了..我正在尝试计算 sha1