ShieldX Toolly
Open a tool Donate
Home Home
Blog Blog
FAQ FAQ
Open a tool Donate
Back to cheatsheets
Privacy

QR Code Security (Quishing)

Decode QR codes and check embedded URLs for phishing — combat the 587% rise in quishing attacks.

2 snippets Intermediate qr-code-security-scanner
QR codequishingphishingimage decode

What you'll learn

  • Decode QR from image (browser)
  • QR URL safety check

How to use these snippets

  1. Click the Copy button next to any snippet to copy it to your clipboard.
  2. Paste the code into your project, IDE, or terminal.
  3. Replace placeholder values (like example.com or your-secret) with your actual data.
  4. Review the code comments for important security notes and caveats.
  5. 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;
}
              
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.

Open the toolkit

Part of the Toolly ecosystem · secure.toolly.site