Skip to content
Back to skills

Qr Crypto

ASecurity

Enforce non-forgeable, time-limited, and anti-replay security standards for QR codes used in the Workspace Factory v9.0 ecosystem.

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 24, 2026
securitytypescriptnodesecurity

Works with

  • cli

Security analysis

A100/100

Pro scans all 5 files and shows the line behind each finding

Scanned November 24, 2026

npx -y skills add iDorgham/Workspace-Factory --skill qr_crypto --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Qr Crypto?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Qr Crypto
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/idorgham-qr-crypto/badge)](https://www.skillsdirectory.com/skills/idorgham-qr-crypto)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
type: Skill
subagents: [core-validator, integrity-bot]
agents: [master-guide, swarm-router]
dependencies: [core-orchestration, global-sync]
version: 1.0.0
---



# SKILL: QR Cryptographic Security & Anti-Replay

## Purpose
Enforce non-forgeable, time-limited, and anti-replay security standards for QR codes used in the Workspace Factory v9.0 ecosystem.

## Core Principles
1.  **HMAC Signing**: All QR payloads must be signed using a server-side secret to prevent tampering.
2.  **Short-Lived Tokens**: QR codes must have an expiration window (e.g., 30-60 seconds) to prevent photo-sharing.
3.  **One-Time Use (Nonce)**: Use unique nonce values per QR to prevent replay attacks during the validity window.

## Implementation Rules
- **Payload Structure**: `{ data: string, exp: number, nonce: string, signature: string }`.
- **Encryption**: Sensitive IDs (like `residentId`) should be encrypted, not just signed, if transmitted in public QR codes.
- **Verification**: The Scanner App must verify:
  1. Signature integrity.
  2. Timestamp (not expired).
  3. Nonce (not previously used in the last 2 minutes).

## Anti-Patterns
- Using static IDs (e.g., `userId: 123`) in a QR code without a signature.
- Storing the HMAC secret in the client/app (must be in server/secure-vault).
- Allowing "infinite" QR validity.

## Code Examples

### Server-Side QR Signing (Node.js)
```typescript
import { createHmac } from "crypto";

export const generateSecureQR = (payload: any, secret: string) => {
  const data = JSON.stringify({ ...payload, exp: Date.now() + 60000 });
  const signature = createHmac("sha256", secret).update(data).digest("hex");
  return Buffer.from(JSON.stringify({ data, signature })).toString("base64");
};
```

### Scanner Verification Logic
```typescript
const verifyQR = (encoded: string, secret: string) => {
  const { data, signature } = JSON.parse(Buffer.from(encoded, "base64").toString());
  const expectedSig = createHmac("sha256", secret).update(data).digest("hex");
  
  if (signature !== expectedSig) throw new Error("Tampered QR");
  const payload = JSON.parse(data);
  if (Date.now() > payload.exp) throw new Error("Expired QR");
  return payload;
};
```

Files in this skill

  • SKILL.md2.1 KB
  • SKILL.md.meta.json789 B
  • core.py336 B
  • manifest.yaml166 B
  • tests/test_core.py278 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in security →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.