Save Leading Zero HEX into String RFID RC522 Arduino
String(mfrc522.uid.uidByte[i], HEX) means you want to convert number into hexadecimal string repesentation, if you pass 4 as input parameter, it will convert it into "4", not "04". You need to apply similar approach as you have used when printing the value through UART. For example:

if (String(mfrc522.uid.uidByte[i] &lt; 0x10) 
  inStringHex += " ";
inStringHex += String(mfrc522.uid.uidByte[i], HEX);


Personally, I would recommend switching from Strings into static buffers (because arduino has too small memory to use dynamic allocation and there could be issue with running out of memory due to memory fragmentation): 

char id[16]; 
sprintf(id, "%02x%02x%02x%02x", mfrc522.uid.uidByte[0], mfrc522.uid.uidByte[1], mfrc522.uid.uidByte[2], mfrc522.uid.uidByte[3]);