base 64 string to hexa string

拈花ヽ惹草 提交于 2019-12-25 07:47:52

问题


How can i conver from base64 string to hexa string (i'm working in ubuntu - c++ code). My hexa string I would like to be like 0x0c....and so on. Need help. Can someone please give me an exaple?Thx!


回答1:


A quick solution that uses common (though not standard) functions:

std::string input = MY_ENCODED_STRING;
unsigned long decoded_value = strtol(input.c_str(), NULL, 64);
char buffer[100] = {0};
std::string output = itoa(decoded_value, buffer, 16);

boost::lexical_cast may be able to provide a more elegant solution (not sure on that one, though).



来源:https://stackoverflow.com/questions/4680441/base-64-string-to-hexa-string

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!