#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]
好奇什麼是錯..我試圖計算SHA1Openssl的SHA1編譯問題
我沒有嘗試你的代碼,怎麼樣刪除IBUF的聲明 – Gisway