Okay - I have this hex data and I have a list of tags:
the raw data may look like this:
5F201A54444320424C41434B20554E4C494D49544544205649534120204F07A00000000310105F24
Because I have a list of tags I can see there are multiple values here Tags [5f20, 4f, 5f24]
Ex: 5F201A54444320424C41434B20554E4C494D49544544205649534120204F07A00000000310105F24…ETC
So - I know that I have this tag [5f20] and its value is all the other stuff in between [5f20] and [4f]. —
I can take this other stuff:
1A54444320424C41434B20554E4C494D4954454420564953412020 and create a string from it which becomes: ("TDC BLACK UNLIMITED VISA“)
I can parse through a small section of it like using:
let string2 =
"5F201A54444320424C41434B20554E4C494D49544544205649534120204F"
var string3: String = ""
if let startRange2 = string2.range(of: "5F20"),
let endRange2 = string2.range(of: "4F")
{
let contents2 = String(string2[startRange2.upperBound..
<endRange2.lowerBound])
print(string3)
string3 = contents2
}
What Im not sure about is: How do I scale this up to work with data where I wont know what tag will be first or second or how many there are? Im seriously stumped and I don't know where to go from here.
Overall my goal is to get create readable data like this: Clean formatted Tags and value
look something like this:
5F201A54444320424C41434B20554E4C494D49544544205649534120204F07A00000000310105F24032307319F160F4243544553542031323334353637389F21031826509A031406179F02060000000000019F03060000000000009F34030203009F120C56495341204352454449544F9F0607A00000000310105F300202019F4E0F616263640000000000000000000000C408491573FFFFFF1097C00A09117101800165E0000AC2820168D9DE289AAD770BE408F6B1D4E0A2576CEA7F03CD479CE3A1827375D6C4D4959ACDB5D3B6F84CD83430F4346C35E48A77A0D5F36FBEA444C2D8701C07FFC7AF06C0485D68F7A83FC30840D3C0766EC4EE669BE5A42BAD4C7459680FAAAE9C4EFEFFEB5A590E53B3E91B3CD28A415C2C9484E26DA5A15592BBCD1F45CF49D27A9D480B031957DF8C790C55FF60DB192CCD070FA4F7BCDC99E7F7567C2F991B5536F9336BA66D68115D54BC3642A9CA47FDD162FCDC33E455AAC283975DACC98CBE9A6611E996F0740072CF8E32D3D9F39F4BB25568F5CC3E7F5DE158E4D62BF4E7185CF13BD068C4F062C26A3BBF88E056F249130E89AA29E52A1EBB6BAD98296822F10949F0C825D1449DA7EF4431AB846D0DDB916F2901359DD9A3B3395BAC9F9BE4D24657F65B030DDADA53577A14D9F5F776B6FF7EAB99D8C4BB08BEF2016C72D94B1DB91BCF0238405B7857646DCE5F79871D96B6A6652090FD8CFCC59973433919A6D0533DFE