Back to cheatsheets
Privacy
QR Code Security (Quishing)
Decode QR codes and check embedded URLs for phishing — combat the 587% rise in quishing attacks.
What you'll learn
- Decode QR from image (browser)
- QR URL safety check
How to use these snippets
- Click the Copy button next to any snippet to copy it to your clipboard.
- Paste the code into your project, IDE, or terminal.
- Replace placeholder values (like
example.comoryour-secret) with your actual data. - Review the code comments for important security notes and caveats.
- Try the interactive related tool to see the concept in action.
Code Snippets
Copy-paste code snippets
2 ready-to-use snippets for qr code security (quishing). Click copy and paste into your project.
Decode QR from image (browser)
// Uses jsQR library
import jsQR from 'jsqr';
async function decodeQR(imageFile) {
const img = await createImageBitmap(imageFile);
const canvas = new OffscreenCanvas(
img.width, img.height
);
const ctx = canvas.getContext('2d');
ctx.drawImage(img, 0, 0);
const imageData = ctx.getImageData(
0, 0, img.width, img.height
);
const code = jsQR(
imageData.data,
imageData.width,
imageData.height
);
return code ? code.data : null;
}
QR URL safety check
function checkQRUrl(url) {
const risks = [];
// Is it a URL at all?
if (!url.startsWith('http://') && !url.startsWith('https://')) {
risks.push('Non-URL payload (could be contact, WiFi, or text)');
return risks;
}
// HTTP (not HTTPS)
if (url.startsWith('http://'))
risks.push('Not HTTPS — unencrypted destination');
// Punycode / homograph
if (url.includes('xn--'))
risks.push('Punycode domain — possible homograph attack');
// URL shortener
const shorteners = ['bit.ly', 'tinyurl.com', 't.co'];
const u = new URL(url);
if (shorteners.includes(u.hostname))
risks.push('Shortened URL — destination hidden');
// Login keywords in path
if (/login|signin|verify|account|wallet/i.test(u.pathname))
risks.push('Login-related path — possible credential harvesting');
return risks;
}
Tool
Related ShieldX tool
Try this concept hands-on with the interactive tool.
100% Free · No signup · No cost
Generate something unguessable right now
148 bits of entropy, a crack-time estimate you can trust, and a clipboard that clears itself after 30 seconds.
Part of the Toolly ecosystem · secure.toolly.site