//depend on <sstream> and <iomanip> include.
//std::string _strLastError
std::ostringstream ostr;
fingerprint = libssh2_hostkey_hash(_session, LIBSSH2_HOSTKEY_HASH_SHA1);
ostr << "Fingerprint: ";
for (int i = 0; i < 20; i++) {
unsigned char c = fingerprint[i];
int nT = c;
ostr << std::hex << std::setw(2) << std::setfill('0') << nT;
}
_strLastError = ostr.str();
编译libssh要注意下面两个问题:
[1] 要依赖的头文件路径不是"D:\sdk\openssl-0.9.8o\include"而是“D:\sdk\openssl-0.9.8o\inc32”
[2]在用Visual Studio打开工程前,可以修改“D:\sdk\libssh2-1.4.3\win32\config.mk”中OpenSSL和Zlib路径的配置。