byte to chart

hy i have question I use rfid Id12 I use this method to turn the badge into a chart but it looks very tricky. It also does not clean me arrays that are dirty to me in the second pass. Is there a better solution?

void onReadTag(byte *tagValue)
{


    Serial.print("got tag: ");
    printTag(tagValue);
    Serial.println("");




          String codest0;
           String codest1;
            String codest2;
             String codest3;
              String codest4;



          codest0= String(tagValue[0], HEX);
          codest1= String(tagValue[1], HEX);
          codest2= String(tagValue[2], HEX);
          codest3= String(tagValue[3], HEX);
          codest4= String(tagValue[4], HEX);



       //   String dataString1;
         String dataString1;
         dataString1  = '#';
         dataString1 += String (codest0);
         dataString1 += String (codest1);
         dataString1 += String (codest2);
         dataString1 += String (codest3);
         dataString1 += String (codest4);


         char message_buff2 [13];
         dataString1.toCharArray(message_buff2,13);


          Serial.println (message_buff2);

All you want to do is print it in hexidecimal? Then just use Serial.print(val, HEX).

If you want to make a string with the hex representation in it then there are methods. But why would you want that?

I think you want to use sprintf.

char message_buff2 [13];
sprintf(message_buff2, "#%02x%02x%02x%02x%02x",
        tagValue[0], tagValue[1], tagValue[2], tagValue[3], tagValue[4]);
Serial.println(message_buff2);

But remember sprinftf() is a bit of a bazooka to do the job. That's a reason why the Print-class doesn't use it. And if you want to return it, message_buff2 may NOT be a local variable.