GithubHelp home page GithubHelp logo

compress qr code data about trigger HOT 12 CLOSED

mwarning avatar mwarning commented on May 12, 2024
compress qr code data

from trigger.

Comments (12)

clach04 avatar clach04 commented on May 12, 2024

I hit this. My real https lock (with certs) is fine so luckily this is not impacting me :-)

For a test shell script with cert (that doesn't really control a lock https://github.com/mwarning/trigger/pull/30/files) I get an error that its too big (larger than 5000 bytes).

from trigger.

mwarning avatar mwarning commented on May 12, 2024

I tried to apply compression, but the result was not significant enough to be useful.

from trigger.

mwarning avatar mwarning commented on May 12, 2024

I was able to fit some certificates (e.g. for google.com) in the QR-Code. No idea how to improve the situation in general.

from trigger.

clach04 avatar clach04 commented on May 12, 2024

I was not able to scan the qrcode with a generic app to look at the payload (scanning from within Trigger works great).

I spent a little time looking at the json export files. I saw a few places in the json payload where there is room for saving some bytes, I do not know if this would apply to qrcode:

  • the json file always contains a dictionary key, even for empty contents. Omitting empty string/null values would save a few bytes
  • the ssh key is noticeably larger (for me double the size) compared with a https key/
    • the ssh key is base encoded multiple times, there is the original plain-text (I think PEM PKCS8) format, this contains plain text markers along with base64 encoded data. Then as a wrapper there appears to be some binary data concatenated with the key, this combined payload is then base64 encoded again. This double encoding does pad out the payload more than needed, however the key is still larger than my sample https cert even if you ignore the double encoding.

Again, I looking at json payload. I'm not sure what the qrcode payload is where space is constrained.

from trigger.

mwarning avatar mwarning commented on May 12, 2024

hm, empty strings and null values should be removed from the QR-Code: https://github.com/mwarning/trigger/blob/v1.9.1/app/src/main/java/com/example/trigger/QRShowActivity.java#L78

from trigger.

mwarning avatar mwarning commented on May 12, 2024

This encoding for the ssh key could be improved. For now I wanted to be sure to get a string that does not contain binary data or the " character.

from trigger.

mwarning avatar mwarning commented on May 12, 2024

The ssh key is also big because it stores the private and public key. Only the private key should be ok, but I do not know yet how to restore the public key from the private one with the library at hand.

from trigger.

mwarning avatar mwarning commented on May 12, 2024

For reference: https://stackoverflow.com/questions/57058149/jsch-create-public-key-from-private-key

from trigger.

mwarning avatar mwarning commented on May 12, 2024

The QR-Code is ~3400 Bytes now. But that is still too big.

from trigger.

clach04 avatar clach04 commented on May 12, 2024

@mwarning good improvement/progress, frustrating results!

I don't need this functionality, json export/import is good for me. But this is an interesting problem. I have an idea for #32, I'll update there.

from trigger.

mwarning avatar mwarning commented on May 12, 2024

The private key is about 512 Bytes (4096 bits), so it should be possible to fit it into the QR code - in theory.

from trigger.

mwarning avatar mwarning commented on May 12, 2024

The used library stores the public key along the private key. There is not much i can do right now. Compression won't help here in a significant way. Closing this for now.

from trigger.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.