下面有个函数,用于将6个字节的字符数组‘转换’到12字节。例如:

 src[6] =
src[6] =  { 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc }
{ 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc }    

 dst[12] =
dst[12] =  { '1','2','3','4','5','6','7','8','9','a','b','c' }
{ '1','2','3','4','5','6','7','8','9','a','b','c' }    因为目标是字符串风格,为了显示需要,dst实际使用的是13字节长度数组,如下:
 unsigned char dst[13];
unsigned char dst[13];

 makeId(dst, src);
makeId(dst, src);    函数如下,麻烦找下Bug。
 void ISLUtil::makeId(unsigned char* id, const unsigned char* ptr)
void ISLUtil::makeId(unsigned char* id, const unsigned char* ptr)


 {
{
 int i = 0;
    int i = 0;
 while(i < 6)
    while(i < 6)

 
     {
{
 unsigned char t = *ptr >> 4;
        unsigned char t = *ptr >> 4;
 if(t >= 0 && t <= 9)
        if(t >= 0 && t <= 9)

 
         {
{
 *id = t + '0';
             *id = t + '0';
 }
        }
 else if(t >= 0x0a && t <= 0x0f)
        else if(t >= 0x0a && t <= 0x0f)

 
         {
{
 *id = t + 'a';
            *id = t + 'a';
 }
        }
 else
        else

 
         {
{
 *id = 0;
            *id = 0;
 }
        }
 
        
 t = (*ptr & 0x0F);
        t = (*ptr & 0x0F);
 ++ id;
        ++ id;
 if(t >= 0 && t <= 9)
        if(t >= 0 && t <= 9)

 
         {
{
 *id = t + '0';
            *id = t + '0';
 }
        }
 else if(t >= 0x0a && t <= 0x0f)
        else if(t >= 0x0a && t <= 0x0f)

 
         {
{
 *id = t + 'a';
            *id = t + 'a';
 }
        }
 else
        else

 
         {
{
 *id = 0;
            *id = 0;
 }
        }
 
        
 ++ ptr;
        ++ ptr;
 ++ id;
        ++ id;
 ++ i;
        ++ i;
 }
    }
 id[12] = '\0';
    id[12] = '\0';
 }
}<----郁闷的分割线---->
    Y的,白痴的错误搞了我两天。。。。