xte*_*408 3 c++ crypto++ visual-c++
我想将myVar转换CryptoPP:Integer为char*或转换为String:代码如下:
CryptoPP::Integer myVar = pubKey.ApplyFunction(m);
std::cout << "result: " << std::hex << myVar<< std::endl;
Run Code Online (Sandbox Code Playgroud)
我一直在互联网上寻找转换CryptoPP:Integer,char*但我找不到运气.所以,无论是转换CryptoPP:Integer到所有人都是一个真正的问题char*,要么我CryptoPP:Integer在C++中都不太了解类型.
有谁可以帮助我吗?
随着提升:
boost::lexical_cast<std::string>(myVar);
Run Code Online (Sandbox Code Playgroud)
C++ 98:
std::ostringstream stream;
stream << myVar;
stream.str();
Run Code Online (Sandbox Code Playgroud)
一种方式,如果CryptoPP::Integer你不清楚地支持<<你的问题暗示的其他方面,那就是使用std::stringstream:
std::stringstream ss;
ss << std::hex /*if required*/ << myVar;
Run Code Online (Sandbox Code Playgroud)
std::string比如提取底层使用std::string s = ss.str();.然后,您可以使用s.c_str()访问const char*缓冲区,只要s在范围内.s一旦您调用并依赖结果c_str()作为行为,并且随后依赖于该结果是不确定的,请不要以任何方式进行更改.
有更简洁的C++ 11解决方案,但这需要你(和我)更多地了解类型.