Sto lavorando su un programma per interfacciare con un certo hardware che sta inviando dati che sono stati codificati e spostati per l'invio all'interno di un blocco CDATA in un documento XML.Qualcuno può identificare questa codifica?
il software nel dispositivo per quanto ne so è scritto in Python e sto scrivendo l'interfaccia in Delphi.
i dati del dispositivo invia è questo
\ x00E \ x18 \ x10 \ x14} * UF! A \ x81 \ xac \ x08 & \ x02 \ x01 \ n \ x15 \ X1A \ xc2PP \ x92 \ x17 \ xc2 \ xc1 \ xa0 \ x0e \ x1a \ xc2 \ xd0K \ x94 \ '\ x830 \ x11 \ x8b \ x84a_ \ xa0 + \ x04 \ x81 \ x17 \ x89 \ x15D \ x91B \ x05. \ x84 \ XF1 \ X1B \ x89% E \ x00 \ x04 \ x9c \ X0E \ XC5 \ XC1 = \ x87 \ x0bE \ xf18 \ x07 \ x1f \ xc8a \ xa5 \ x95 \ x08H \ x80? \ x84 \ x18 \ TPK \ X8A $ \ t \ xf1 \ xb2 \ x8e (J \ xb0 \ x08 \ x91 \ x1eJ \ xf0W \ x0c- \ x0b \ xf0 \ x0e \ x88 \ x07 \ x0c \ x00 \ x9b \ n \ x910Z \ x06! \ x92 \ xf0W \ x073S \ x08 \ x87 \ xff \ xff \ xff \ xff \ xff \ xff \ xff \ xff \ xff \ xff \ xff \ xff \ x0 \ xff \ xff \ xff \ xff \ xff \ xf4C \ xed \ xbb \ xb9_ \ xffDD1 \ r \ xcb \ xbaw \ xf5TD2 \ sso \ xbb \ XBA \ x8 8EUDB \ x0c \ XBA \ xaa \ x99UUDB \ x0c \ XBA \ xaa \ xa9UUD2 \ r \ xbb \ xaa \ xaaUTD2 \ r \ xcb \ xbb \ xaaUTC! \ R \ xcb \ xbb \ xbbUD3! \ X0E \ xdc \ xbb \ xbbDD3! \ X0E \ xdc \ XCC \ xbbDC2! \ X0E \ xdc \ XCC \ xcc33 "\ x11 \ X0E \ xdd \ XCC \ xccC3" \ x11 \ X0E \ sso \ xdc \ XCC \ xf33! \ x10 \ X0E \ XEE \ xdd \ XCC \ xf32! \ x10 \ X0E \ XEE \ xdd \ xdc \ xff2! \ x10 \ x00 \ XEE \ XEE \ xdd \ xff \ XF2! \ x11 \ x00 \ X0E \ XEE \ xdd \ xff \ XF2! \ x11 \ x10 \ X0E \ XEE \ XEF \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00
Devo essere in grado di inviare dati simili al dispositivo ma il formato in cui lo ho inserito è questo
0x451C0E148A4A65781B0291080E1644B0680B340580A28615C9001E8F1EC9F0559D260A4147901A0AF16D93304BC09A8523CC513E25218CA00CD42C0CE137891FCDB02397054DD07C04124E112408158E5124841E0ED17F8E28CEE12C96284F511B231C8FB07C1228D09079BD31D090960B2050B075871CD1217B8D171131830B3552509A8E295271621D2E9271AD972ED371AB93FFFCDFFFFFFFFFFFFCDDFFFFFFFFFFBCCDE0122FFFFFBCCDE01123FFFBBBCDE011234FFAABCDE0FFAABCCE0FFAAABCDEFFAAABCDEFFAAAABCE01344FAAA99ABE12344FAAA99ABE124555FAA99AAC044555FAA9999A96655FFAA9989998765FFAA98899BB855FFAA9999ABBD45FFAA9999ABCD34FAAA999AABCD345FAAA999BBCD33F000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
So che \ x viene in genere utilizzato per rappresentare caratteri ascii usando i loro valori esadecimali in coppie di 2 cifre ma guardando i dati questo non è il caso. sto lottando per identificare la codifica utilizzata e il produttore non fornisce molto aiuto.
quello che voglio sapere è come convertire l'hex che ho nel formato che usano in Delphi xe4?
proposito i due blocchi non contengono gli stessi dati, ma è lo stesso tipo di dati, cioè il formato è la stessa codifica solo diverso
esempio dei dati inviati
POST ******** HTTP/1.1 Host: 172.16.1.136:8080 Accept-Encoding: identity Content-Length: 1552 Content-Type: text/xml Authorization: 1344354:PASS User-Agent: *********
<?xml version="1.0" encoding="utf-8"?> <Biometrics> <Templates>
<Template badge="1075" readerType="6" index="6" ts="2014-11-06T17:28:40.000+01:00" chk="3a6a4924ec04e668186b15e244e6fe73"> <![CDATA[ ['1075_6',
1415294920.3754971, [0, 0], [['3\x04\x00\x00\x00P\x00\x00E\x18\x10\x14}*UF!A\x81\xac\x08&\x02\x01\n\x15\x1a\xc2PP\x92\x17\xc2\xc1\xa0\x0e\x1a\xc2\xd0K\x94\'\x830\x11\x8b \x84a_\xa0+\x04\x81\x17\x89\x15D\x91B\x05.\x84\xf1\x1b\x89%E\x00\x04\x9c\x0e\xc5\xc1=\x87\x0bE\xf18\x07\x1f\xc8a\xa5\x95\x08H\x80?\x84\x18\tPK\x8a$\t\xf1\xb2\x8e(J\xb0\x08\x91\x1eJ\xf0W\x0c-\x0b\xf0\x0e\x88\x07\x0c\x00\x9b\n \x910Z\x06!\x92\xf0W\x073S \x08\x87\xff\xff\xff\xf0\x0e\xff\xff\xff\xff\xff\xf3\x10\x0e\xba\xff\xff\xff\xf4C \xed\xbb\xb9_\xffDD1\r\xcb\xbaw\xf5TD2\xed\xbb\xba\x88EUDB\x0c\xba\xaa\x99UUDB\x0c\xba\xaa\xa9UUD2\r\xbb\xaa\xaaUTD2\r\xcb\xbb\xaaUTC!\r\xcb\xbb\xbbUD3!\x0e\xdc\xbb\xbbDD3!\x0e\xdc\xcc\xbbDC2!\x0e\xdc\xcc\xcc33"\x11\x0e\xdd\xcc\xccC3"\x11\x0e\xed\xdc\xcc\xf33!\x10\x0e\xee\xdd\xcc\xf32!\x10\x0e\xee\xdd\xdc\xff2!\x10\x00\xee\xee\xdd\xff\xf2!\x11\x00\x0e\xee\xdd\xff\xf2!\x11\x10\x0e\xee\xef\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00']]] ]]> </Template>
</Templates> </Biometrics> HTTP/1.1 200 OK Server: Apache-Coyote/1.1 Content-Type: text/xml;charset=ISO-8859-1 Transfer-Encoding: chunked Date: Thu, 06 Nov 2014 17:28:41 GMT
52 <?xml version="1.0" encoding="UTF-8"?><OperationStatus uid="">OK</OperationStatus> 0
Questi sono i modelli biometrici usati da Suprema Reader se ciò aiuta.
Soluzione
ho decifrato con successo quello che sta succedendo con questo ora. per trasformare la mia stringa esadecimale originale nel formato richiesto sto usando questo codice, spero che questo aiuti qualcun altro in futuro. Non esitate a commentare e formulare suggerimenti per migliorare il codice.
class function TConvert.HexToPythonEscAscii(const aHexString: string): string;
var
i: Integer;
ByteArray: array of Byte;
begin
Result := '';
SetLength(ByteArray, (length(aHexString) div 2));
TConvert.HexToBytes(aHexString, ByteArray, length(ByteArray));
for i := Low(ByteArray) to High(ByteArray) do
begin
if ByteArray[i] in [$20..$7E] then
begin
case ByteArray[i] of
$5c : Result := Result +'\\';
$27 : Result := Result +'\''';
else
Result := Result + char(ByteArray[i])
end;
end
else
begin
case ansichar(ByteArray[i]) of
TAB : Result := Result + '\t';
LF : Result := Result + '\n';
CR : Result := Result + '\r';
else
Result := Result + '\x' + LowerCase(IntToHex(ByteArray[i], 2));
end;
end;
end;
end;
Sembra una domanda per http://reverseengineering.stackexchange.com/. – TLama
Sembra testo binario anziché codificato. Cosa dicono i documenti? –
Come per il \ x che è solo un byte rappresentato come esadecimale. Tutto il resto è ascii. –