whatisgithub

What is qr-swastika-avoider?

marc-alexis-com/qr-swastika-avoider — explained in plain English

Analysis updated 2026-05-18

18RustAudience · developerComplexity · 2/5LicenseSetup · easy

In one sentence

A Rust crate that detects accidental swastika-shaped patterns in generated QR codes and can produce a guaranteed clean, still scannable code instead.

Mindmap

mindmap
  root((qr-swastika-avoider))
    What it does
      Detects hooked cross pattern
      Generates clean QR codes
      Zero dependency detector
    Tech stack
      Rust
    Features
      Function aware scan
      Contrast aware scan
      Safe generation
    Adapters
      qrcodegen
      qrcode
      fast_qr
      Raw grid
    Scope
      Axis aligned only
      Two sizes covered
      Diagonals out of scope

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Check a QR code you already generated for an accidental hooked-cross pattern before publishing it.

USE CASE 2

Generate a QR code that is guaranteed free of the pattern while staying scannable.

USE CASE 3

Plug detection into an existing QR generation pipeline using qrcodegen, qrcode, or fast_qr.

USE CASE 4

Add an automated safety check to a QR code generator used by a product or website.

What is it built with?

Rust

How does it compare?

marc-alexis-com/qr-swastika-avoideradindazu/ultimatevocalapplicative-systems/gcan
Stars181818
LanguageRustRustRust
Setup difficultyeasymoderateeasy
Complexity2/52/52/5
Audiencedeveloperdeveloperops devops

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min

The default build has zero dependencies, optional cargo features add adapters for specific QR libraries or the safe-generation function.

Free to use, modify, and redistribute for any purpose, including commercial use, as long as you keep the copyright notice.

So what is it?

QR codes are drawn using one of eight interchangeable mask patterns, and the standard picks whichever mask scores best for readability without ever checking what shapes appear in the result. Because of that, a swastika shaped pattern can occasionally appear by chance in a generated QR code, especially in small or thin motifs. This Rust crate exists specifically to catch that problem: it detects when a hooked cross pattern has appeared in a QR code, and it can optionally generate a code that is guaranteed not to contain one. The core detector has no external dependencies and works with any QR code representation through a small two method trait, so it can plug into whatever QR generating library you already use. It is careful to avoid false positives: it excludes the finder, timing, alignment, and format or version sections of a QR code from its scan, so a normal structural corner of the code is never mistaken for the pattern it is looking for, and it also ignores a motif that would be invisible anyway because it blends into same colored modules around it. For detecting an existing code, you pass in the QR code's module grid and get back a true or false answer. Built in adapters exist for the popular qrcodegen, qrcode, and fast_qr Rust crates, plus a raw grid representation, each gated behind its own optional cargo feature so you only pull in what you need. For generating a new code, an optional encode_safe function renders all eight standard masks, filters out any that contain the pattern, and returns the cleanest remaining option, so you still get the same readability optimization the QR standard normally provides, just with the unwanted pattern ruled out or an explicit error if none can be found. The detector's scope is intentionally narrow: it targets the classic axis aligned hooked cross shape at two specific sizes, in both mirror directions and both color polarities, within a small tolerance. Diagonal or rotated versions of the pattern are outside what it currently checks for. The crate is licensed under the MIT license.

Copy-paste prompts

Prompt 1
Show me how to add qr-swastika-avoider to a Rust project that already uses the qrcodegen crate.
Prompt 2
Explain how encode_safe picks a mask while avoiding a swastika-shaped pattern.
Prompt 3
Help me write a test that confirms a raw QR module grid does not contain the detected pattern.
Prompt 4
What sizes and orientations of the pattern does this crate currently detect and what does it miss?

Frequently asked questions

What is qr-swastika-avoider?

A Rust crate that detects accidental swastika-shaped patterns in generated QR codes and can produce a guaranteed clean, still scannable code instead.

What language is qr-swastika-avoider written in?

Mainly Rust. The stack also includes Rust.

What license does qr-swastika-avoider use?

Free to use, modify, and redistribute for any purpose, including commercial use, as long as you keep the copyright notice.

How hard is qr-swastika-avoider to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is qr-swastika-avoider for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.