Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zlib header form aztec is different #2

Closed
jurkov opened this issue Jun 13, 2018 · 11 comments
Closed

zlib header form aztec is different #2

jurkov opened this issue Jun 13, 2018 · 11 comments

Comments

@jurkov
Copy link

jurkov commented Jun 13, 2018

Hello,
the zlib header of my tickets are 0x78, 0x3f and not 0x78, 0x9c. Do you have any idea how to decode the content?

@justusjonas74
Copy link

I'm not a maintainer of the project, but interested in the ticket data. Could you upload a sample ticket?

@justusjonas74
Copy link

Another idea: Which lib/tool do you use for reading the barcode. I had some troubles with 'zxing' (and all other libs using zxing) due to the encoding.

I fixed it like this (sure not the best way):

var iconv = require('iconv-lite')
function fixingZXing (buffer) {
  const latin1str = iconv.decode(buffer.toString('utf-8'), 'ISO-8859-1')
  return Buffer.from(latin1str, 'latin1')
}

@justusjonas74
Copy link

The barcode isn't a UIC-918.3 barcode. UIC-918.3 is the main data format for rail traffic tickets. The barcode on the PDF is a VDV Barcode or Statische Berechtigung. This is a special format which is only used in Germany for local transport. It's not supported by this lib.

The specs of this format are published here (German only).

const extractAztec = require('ot-aztec-extract');
const zxing = require('zebra-crossing');
const TicketParser = require('ticket-parser');
const iconv = require('iconv-lite');
const fs = require('fs');


function read(pdfPath) {
  return extractAztec(fs.readFileSync(pdfPath))
  .then(png => zxing.read(png, { pureBarcode: true }))
  .then(data => iconv.encode(data.raw, 'latin1'))
  .then(x => console.log(x.toString()))
}

read('./flt-3ww74b4100-0.pdf')

Output (look for VDV):

���\�
��     ����s��D�vaI�0c��),���q��eaF�\F��c�qo�� ��+ �~�ޗl���<��t�d�
WRr���vݚ�.�P�eT���
                  ���(Q�        �����
                                     �:�4�.�.�}�VDV!��_7��z~����f�����*�ؽ�s��a��k7Rg
                                                                                    Q�����ۇyJ􊹬�[�|��l�����s
?��@Wu������>�'�`zÚ�o!�b�b⯏++�yi��p���#��_8�DEVDV�/�[������2���I S

@pbock
Copy link
Owner

pbock commented Jun 13, 2018

TIL, because of course there’s a separate format. Thanks for diagnosing this, @justusjonas74!

@justusjonas74
Copy link

Anyone interested in a lib for parsing this format? I guess it's a bit more complex than the UIC barcode...

@pbock pbock closed this as completed Jun 25, 2018
@vkrause
Copy link

vkrause commented Dec 8, 2019

We have a decoder for the VDV format here now: https://github.com/KDE/kitinerary/tree/master/src/vdv, that at least gets you past the crypto to the actual payload. There's a number of operator-specific numbers and codes in there that this can't translate yet, but it for example finds some privacy-relevant details in the above sample, such as name, gender and birthdate.

@pbock
Copy link
Owner

pbock commented Dec 8, 2019

That’s great news! Do you think it would make sense to include VDV compatibility in this library? In that case I’d be grateful for any help because I have no experience with linking to non-JS libraries and no longer live in Germany (which makes testing difficult and dependent on donated data).

I suppose there might also be an incompatibility between the MIT and GNU licences.


As a precaution, I’ve removed this comment by @jurkov due to potential personal data in the linked PDF:

I'm sorry i can't give you my pdf. But you can try this [redacted]

I used zebra-crossing and ot-aztec-extract as descript in #1 .
To get the content of the aztec use

function read1(pdfPath) {
var ret = extractAztec(fs.readFileSync(pdfPath))
.then(png => zxing.read(png, { pureBarcode: true }))
.then(data => iconv.encode(data.raw, 'latin1'))
.then(data => fs.writeFileSync('blob.blob', data))
}

Originally posted by @jurkov in #2 (comment)

Repository owner deleted a comment from jurkov Dec 8, 2019
@vkrause
Copy link

vkrause commented Dec 9, 2019

I have no idea about the integration, neither technically nor from a use-case POV, sorry. I mainly posted this here as this is one of the very few public discussions on this subject I found while digging into this.
In case someone wants to integrate the VDV code elsewhere I'm of course happy to discuss how to support and simplify that, both technically and regarding licenses, if that should turn out to be a problem :)

@pbock
Copy link
Owner

pbock commented Dec 9, 2019

Thanks! As I have neither the know-how nor much of a use-case, I’ll add a few words to the readme in the hopes of pointing people in the direction of this discussion. Pull requests are gladly accepted!

@mBednarz92
Copy link

I have no idea about the integration, neither technically nor from a use-case POV, sorry. I mainly posted this here as this is one of the very few public discussions on this subject I found while digging into this. In case someone wants to integrate the VDV code elsewhere I'm of course happy to discuss how to support and simplify that, both technically and regarding licenses, if that should turn out to be a problem :)

As I am fighting with some project related to reading and parsing data of VDV ticket. Can I kindly ask you to share your solution again? I can see that is no longer avalible for some reason :(

@mBednarz92
Copy link

Anyone interested in a lib for parsing this format? I guess it's a bit more complex than the UIC barcode...

I am working on that as my job project, but I think it would be extremely useful if we could share this lib as open source. Let me know if interested :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants