Visa Developer Community

Regular Visitor

QR generation CRC algorytm

Hi there,

 

I would like to generate QRcode for merchant Erlang-app. 

Currently, I can combine the QRCode by mVISA Technical Specifications 20.05.2017

 

I generate a Tag63(CRC) by predefined standarts(CRC-16/CCITT-FALSE ,CRC-16/ARC ,CRC-16/AUG-CCITT,CRC-16/BUYPASS,CRC-16/CDMA2000,CRC-16/DDS-110,CRC-16/DECT-R,CRC-16/DECT-X,CRC-16/DNP,CRC-16/EN-13757,CRC-16/GENIBUS,CRC-16/MAXIM,CRC-16/MCRF4XX,CRC-16/RIELLO,CRC-16/T10-DIF,CRC-16/TELEDISK,CRC-16/TMS37157,CRC-16/USB,CRC-A ,CRC-16/KERMIT,CRC-16/MODBUS,CRC-16/X-25,CRC-16/XMODEM), but it seems that the CRC is not correct.

 

Example: 00020101021202164311190000119821520415205303356540515.815802IN5903KFC6006MUMBAI6304e378

  

Could you please help provide a method to calculate CRC  by Erlang (or Java/Go/PHP)?

 

 

 

Tags (1)
3 REPLIES 3
Frequent Helper

Re: QR generation CRC algorytm

Hello,

 

We are looking into the below request. Will keep you posted.

 

Thanks,
Jai

Regular Visitor

Re: QR generation CRC algorytm

 

I solved this problem 

Erlang

crc16(Data) ->
crc16(Data, 16#ffff).
crc16(<<>>, CRC) ->
CRC;
crc16(<<B:8, Else/binary>>, CRC) ->
crc16(Else, ((CRC bsl 8) band 16#ffff) bxor
element(((CRC bsr 8) bxor B) + 1, ?CRC16Table)). 

 

<<"16#", QrCodeCRC/binary>> = list_to_binary(io_lib:format("~.16#",[crc:crc16(QrCodeBody)]))

variable QrCodeCRC contains 4 bytes of checksum for tag63

Highlighted
Frequent Helper

Re: QR generation CRC algorytm

This is great @gadina. Thanks for sharing the solution with the community members.