基地64串六弦 [英] base 64 string to hexa string

查看:175
本文介绍了基地64串六弦的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从Base64的字符串作为字符串六(我在Ubuntu的工作 - C ++ code)CONVER。我的六弦我想成为像....的0x0C等。需要帮助。是否有人可以给我的exaple?THX!

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!

推荐答案

这是使用通用(虽然不是标准)功能的快速解决方案:

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的也许能够提供更完美的解决方案(不知道在那一个,虽然)。

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

这篇关于基地64串六弦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆