//字节数组转换为HEX 字符串
const string Byte2HexString(const unsigned char* input, const int datasize)
{
char output[datasize*];
for(int j = ; j < datasize; j++ )
{
unsigned char b = *(input+j);
snprintf( output+j * ,, "%02x",b);
}
return string(output) ;
}
/*
* 把16进制字符串转换成字节数组 @param hex @return
*/
unsigned char* HexString2Byte(string hex)
{
int len = (hex.length() / );
unsigned char* result = new unsigned char[len];
//const char* achar = hex.c_str();
for (int i = ; i < len; i++) {
int pos = i * ; QString lStr(hex[pos]);
int iLeft = lStr.toInt(NULL, ); QString rStr(hex[pos+]);
int iRight = rStr.toInt(NULL, ); int iNew = ( iLeft<< | iRight);
result[i] = (unsigned char) iNew;
}
return result;
}

调用演示:

BYTE face_feature[];

//16进制字符串转换为字节数组
unsigned char* pFeature = HexString2Byte(strFeature);
memcpy(face_feature, pFeature, strFeature.length()/); //字节数组转换为16进制字符串
string strFeature = Byte2HexString(face_feature,);

最新文章

  1. 在Thinkphp中使用AJAX实现无刷新分页
  2. 阿里云centos安装svn和submin
  3. JavaScript基础------入门基础
  4. DbHelperSQL 判断数据库表结构公用方法
  5. 微信热修复tinker及tinker server快速接入
  6. 配置 VS 2015 开发跨平台手机应用
  7. 在WPF中使用ArcGIS Engine
  8. chrome浏览器访问google插件
  9. Libgdx 1.6.1发布,跨平台游戏开发框架
  10. 【进阶1-3期】JavaScript深入之内存空间详细图解(转)
  11. 如何使用HttpClient包实现JAVA发起HTTP请求?
  12. Codeforces Round #505 (Div 1 + Div 2 Combined) Solution
  13. Django-website 程序案例系列-5 模态对话框实现提交数据
  14. HTML格式化标签
  15. centos7部署openvpn-2.4.6
  16. [UE4]name slot一个种应用技巧
  17. MySQL数据行溢出的深入理解
  18. 关于安装VS2010过程中的错误
  19. C#treeView控件单击事件选中节点滞后问题解决方法
  20. [转载]meclipse中project facet问题

热门文章

  1. DataContract和DataMember的作用
  2. 使用 PowerShell 管理 Azure 磁盘
  3. SQL Server全文搜索(转载)
  4. If TransactionScope will close database connections
  5. SQL SERVER中关于OR会导致索引扫描或全表扫描的浅析 (转载)
  6. C#实现复制文件夹中文件到另一个文件夹的方法
  7. cut切割,简单的取列
  8. 乘风破浪:LeetCode真题_033_Search in Rotated Sorted Array
  9. 【2017下集美大学软工1412班_助教博客】团队编程2-需求分析&amp;原型设计团队成绩公示
  10. 树莓派3B+ wifi 5G连接