Skip to content

Instantly share code, notes, and snippets.

Last active Mar 2, 2022
What would you like to do?
Extract JSON object from QR code
// Extract JSON payload from SHC QR code (without any kind of private/public key verification)
// Credits + inspiration
// Usage
// $ node shc.js "shc:/01234569…"
const zlib = require("zlib");
// Extract the QR data from arguments
const data = process.argv[2];
// Convert the data to a JWT and extract its base64-encode payload
const payload = data
.map((number) => String.fromCharCode(parseInt(number, 10) + 45))
// Decode the payload
const buffer = Buffer.from(payload, "base64");
// Uncompress the payload and print the result
zlib.inflateRaw(buffer, (err, result) => {
Copy link

sylvainfilteau commented May 14, 2021

docker run -it --rm --name shc -v `pwd`/shc.js:/usr/src/app/shc.js node:16 node /usr/src/app/shc.js <qr code content>

Copy link

fproulx-boostsecurity commented May 17, 2021

Copy link

gregsadetsky commented May 20, 2021

Merci @remi! :-)

Copy link

007Quebec commented Sep 19, 2021

Salut jai le string jwt jaimerais le convertir en format shc :/ pour cree un code QR pouvez vous maidez

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment