Italian Barcode in base45

Luca1967

Active Member
Devo leggere un qrcode in base45 e decodificarlo.
Per intenderci all'interno del qrcode c'è questo

RRQXO8O608CKHP9L20UH95DBHM9646646746+34+RAZODQW6946846746SW60E091ASF6746 1B01B1A6W479%6NY9646746TH0F4D%/O.O0$S9WU0LF6$96646Q*027BZ*2.U78OQNK7E7AWZ4II6BFF9D0%31OHPU76:Y1XDEV11-77R:CSHNSAJI8S3RPPWF:ENQJLR333BNC%F*DDU36UUL40R.$T

che decodificato viene tradotto in

0oRDoQEmoFhLpwBvSkxZUUsgMDAwMDAxIFNUAWswNTAwMzAyMDE1MgJ2T1AyNTAxV1RXMDE5ODM2LU1CMDAwMQMaZ5jFjQRiTEIFZjIuMTAwMAb1WEAW0DzP0eo6+lBjJesysnlVAlIIlsjWMM8OD3EoCDU4w2bDuQiYKd72yoN8YLiRqY4YXbfhfWFpRTAbq4HVl+wQ


Questa è una stringa CBOR/Cose che deve esserre decodificata per ottenere il json.


C'è qualcuno che ha già approcciato questo problema e magari ha un sorgente in B4A per fare queste decodifiche?

Grazie molte
 

drgottjr

Expert
Licensed User
Longtime User
prima di tutto, la tua conversione da base45 a cbor è sbagliata. è necessario una stringa hex prima di decodifare. questa decodificazione non è difficile, ma hai bisogno di una "libreria" cbor, di che ci sono varie. inoltre, hai bisogno di certa conoscenza di cbor. con javaobject si può fare la decodificazione.

stringa cbor in hex:
D28443A10126A0584BA7006F4A4C59514B20303030303031205354016B303530303330323031353202764F50323530315754573031393833362D4D4230303031031A6798C58D04624C420566322E3130303006F5584016D03CCFD1EA3AFA506325EB32B2795502520896C8D630CF0E0F7128083538C366C3B9089829DEF6CA837C60B891A98E185DB7E17D616945301BAB81D597EC10 300
Array size: 1
this dataitem looks like a cbor ARRAY
Item type: Array
Array size: 4
Item type: ByteString <----- byte[]
Here is the hex value: A10126
but unless you know what they represent, they won't go much good.
Item type: Map
Map contents:
Item type: ByteString <----- byte[]
Here is the hex value: A7006F4A4C59514B20303030303031205354016B303530303330323031353202764F50323530315754573031393833362D4D4230303031031A6798C58D04624C420566322E3130303006F5
but unless you know what they represent, they won't go much good.
Item type: ByteString <---- byte[]
Here is the hex value: 16D03CCFD1EA3AFA506325EB32B2795502520896C8D630CF0E0F7128083538C366C3B9089829DEF6CA837C60B891A98E185DB7E17D616945301BAB81D597EC10
but unless you know what they represent, they won't go much good.

allora, queste 2 stringhe hex:
A10126
e
A7006F4A4C59514B20303030303031205354016B303530303330323031353202764F50323530315754573031393833362D4D4230303031031A6798C58D04624C420566322E3130303006F5
e
16D03CCFD1EA3AFA506325EB32B2795502520896C8D630CF0E0F7128083538C366C3B9089829DEF6CA837C60B891A98E185DB7E17D616945301BAB81D597EC10

sono 3 stringhe cbor all'interno della stringa originale...

risulta che posso leggere la prima stringa e la seconda:
{ 1: -7 }

{ 0: JLYQK 000001 ST, 1: 05003020152, 2: OP2501WTW019836-MB0001, 3: 1738065293, 4: LB, 5: 2.1000, 6: TRUE }

ti dice qualcosa?


l'altra terza stringa è "riservata": could not parse: co.nstant.in.cbor.CborException: Reserved additional information

la stringa originale non si legge facilmente dati questi passi fatti
 
Last edited:

Luca1967

Active Member
Mi spiego meglio.
questa stringa : RRQXO8O608CKHP9L20UH95DBHM9646646746+34+RAZODQW6946846746SW60E091ASF6746 1B01B1A6W479%6NY9646746TH0F4D%/O.O0$S9WU0LF6$96646Q*027BZ*2.U78OQNK7E7AWZ4II6BFF9D0%31OHPU76:Y1XDEV11-77R:CSHNSAJI8S3RPPWF:ENQJLR333BNC%F*DDU36UUL40R.$T

l'ho decodificata in base 45 in binary e L'array di byte che si ricava dalla decodifica base45 è una struttura dati binaria firmata nel formato COSE_Sign1.

Convertito il binary in testo ottengo questo

0oRDoQEmoFhLpwBvSkxZUUsgMDAwMDAxIFNUAWswNTAwMzAyMDE1MgJ2T1AyNTAxV1RXMDE5ODM2LU1CMDAwMQMaZ5jFjQRiTEIFZjIuMTAwMAb1WEAW0DzP0eo6+lBjJesysnlVAlIIlsjWMM8OD3EoCDU4w2bDuQiYKd72yoN8YLiRqY4YXbfhfWFpRTAbq4HVl+wQ

Il payload dell'oggetto firmato è costituito da un "dictionary" (o mappa) in formato CBOR con indice numerico e contenente le seguenti informazioni:

0. Numero FIR
1. Codice fiscale soggetto
2. Numero iscrizione Unità Locale (*)
3. Data rilascio (secondi da Epoch)
4. Sigla CCIAA
5. Identificativo certificato
6. Demo flag


Non riesco a estrarre il payload


ci sono dei sorgenti b4a che possono fare questo?
 

drgottjr

Expert
Licensed User
Longtime User
questa non è la mappa: { 0: JLYQK 000001 ST, 1: 05003020152, 2: OP2501WTW019836-MB0001, 3: 1738065293, 4: LB, 5: 2.1000, 6: TRUE } ??
e questa non è la data: 2025-01-28T12:54:53+01:00 ??
Il payload dell'oggetto firmato è costituito da un "dictionary" (o mappa) in formato CBOR con indice numerico e contenente le seguenti informazioni:

0. Numero FIR
1. Codice fiscale soggetto
2. Numero iscrizione Unità Locale (*)
3. Data rilascio (secondi da Epoch)
4. Sigla CCIAA
5. Identificativo certificato
6. Demo flag

Non riesco a estrarre il payload
1: 05003020152 =
  • Partita IVA: 00798290961 - Codice Fiscale: 05003020152
  • Rag. Sociale: LA NETTATUTTO S.R.L.
3: 1738065293
 
Last edited:

Luca1967

Active Member
questa non è la mappa: { 0: JLYQK 000001 ST, 1: 05003020152, 2: OP2501WTW019836-MB0001, 3: 1738065293, 4: LB, 5: 2.1000, 6: TRUE } ??


1: 05003020152 =
  • Partita IVA: 00798290961 - Codice Fiscale: 05003020152
  • Rag. Sociale: LA NETTATUTTO S.R.L.
E' corretto, ma come hai fatto?
C'è il codice il b4a?
 

drgottjr

Expert
Licensed User
Longtime User
hai bisogno di una "libreria" cbor. e per usarla con b4a, è necessario un "involucro", che - per quanto ne so - non esiste.
se conosci java, è possibile usare la libreria con javaobject (a secondo della complessita della libreria - abbastanza, direi) oppure direttamente (funziona bien con b4a). b4a è perfetto per questo lavoro, ma si tratta di un tema specializzato per il quale non troverai soluzioni già fatte. mettiamoci al lavoro!
 

Luca1967

Active Member
io ho preso la libreria cbor-4.4.4.jar, pensi che possa andare bene?
Oppure tu mi puoi spiegare che procedura hai fatto per estrarre i dati?

Grazie molte
 

drgottjr

Expert
Licensed User
Longtime User
non so di che json parli. ho letto la mappa senza json. penso che qualsiasi libreria potrebbe bastare. prova qualcosa, correggi e riprova. se la stringa ha elementi nidificati, vedrai cuanto è difficile. e non parliamo di crittografia. una stringa cbor semplice si legge semplicemente. se sei fortunato troverai un semplice cbor.
 
Top