QR扫描交换字符

huangapple go评论77阅读模式
英文:

QR scan swapping characters

问题

I am currently working with a QR made with qrcode https://davidshimjs.github.io/qrcodejs/

But I have trouble while reading it.

The content of the QR is checked before sending and is a JWT token like this one:

eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ7XCJ0YXJqZXRhXCI6XCIqKioqNCoqKioqKioqKlwiLFwibm9tXCI6XCIqKioqKioqKioqKioqKlwifSIsImlhdCI6MTY4NjMwODcwODk5MX0.IajSQzRdC3PkxI4opTbwk-bqcCE-75z9whYQwt5Z2nFwVLGjHZRbTcjC1dy-jyTpPbVsWimQU96jxynopepCXQ

But when I scan my QR what is being sent in the network is the same token but swapping the '-' with '''

eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ7XCJ0YXJqZXRhXCI6XCIqKioqNCoqKioqKioqKlwiLFwibm9tXCI6XCIqKioqKioqKioqKioqKlwifSIsImlhdCI6MTY4NjMwODcwODk5MX0.IajSQzRdC3PkxI4opTbwk'bqcCE'75z9whYQwt5Z2nFwVLGjHZRbTcjC1dy'jyTpPbVsWimQU96jxynopepCXQ

This makes us unable to decode our token, so I would like to know two things:

  1. Why is this happening?
  2. What would be the best approach to solve it.

Thanks.

EDIT 1: UPDATE

If I can scan the QR with a different app, like my mobile app, I can read the QR in the right way. So the problem is not in the QR but in the way that they read the QR and send it to the backend. I will delete the JWT and QR-Code TAGS.

英文:

I am currently working with a QR made with qrcode https://davidshimjs.github.io/qrcodejs/

But I have trouble while reading it.

The content of the QR is checked before sending and is a JWT token like this one:

eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ7XCJ0YXJqZXRhXCI6XCIqKioqNCoqKioqKioqKlwiLFwibm9tXCI6XCIqKioqKioqKioqKioqKlwifSIsImlhdCI6MTY4NjMwODcwODk5MX0.IajSQzRdC3PkxI4opTbwk-bqcCE-75z9whYQwt5Z2nFwVLGjHZRbTcjC1dy-jyTpPbVsWimQU96jxynopepCXQ

But when i scan my QR what is being send in the network is the same token but swapping the '-' with '

eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ7XCJ0YXJqZXRhXCI6XCIqKioqNCoqKioqKioqKlwiLFwibm9tXCI6XCIqKioqKioqKioqKioqKlwifSIsImlhdCI6MTY4NjMwODcwODk5MX0.IajSQzRdC3PkxI4opTbwk'bqcCE'75z9whYQwt5Z2nFwVLGjHZRbTcjC1dy'jyTpPbVsWimQU96jxynopepCXQ 

This make us unable to decode our token so i would like to know two thing:

  1. Why is this happening?
  2. What would be the best approach to solve it.

Thanks.

EDIT 1: UPDATE

If i can the QR with a different app, like my mobile app the qr I can read the qr in the right way so the problem is not in the QR but in the way that they read the QR and send it to the backEnd. I will delete the JWT and QR-Code TAGS.

答案1

得分: 0

与供应商交流后,似乎问题不在于代码,而在于不同的QR扫描器配置,更确切地说,他们尝试使用的某些QR扫描器不使用UTF-8,而是使用其他ISO标准,这些ISO标准不允许一些特殊字符。

如果我们在编码QR码时使用特殊字符,这将使他们无法解码QR码。

最简单的解决方案是将JWT编码为Base 64,以避免需要检查每个QR扫描器。

英文:

After talking with our provider it seems like the problem is not in the code but in the configuration of the different QR scanners they where trying to use, to be more exact, some of the QR scans they are currently using don´t work with UTF-8 but with other ISO that doesn´t allow some special characters.

This make impossible for them to decode a QR code if when coding it we have special characters.

The easiest solution is to encode the JWT in base 64 to avoid the need to check every QR scanner

huangapple
  • 本文由 发表于 2023年6月12日 14:23:08
  • 转载请务必保留本文链接:https://go.coder-hub.com/76454043.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定