Skip to content

Deterministic GitHub-style identicon generator with 39 bits of entropy (≈550M possibilities). Same input → same icon, like a hash, but not cryptographically secure.

Notifications You must be signed in to change notification settings

Naman-0206/Identicons-API

Repository files navigation

Identicon API

Generate deterministic, GitHub-style identicons from any input string (e.g., username or user ID), with an option to generate random identicons. Identicons (“identity icons”) are simple visuals derived from an identifier so users get a consistent avatar without uploading an image.

Features

  • 🎯 Deterministic identicons from any string (username, user ID, email, etc.).
    • Not globally unique, but the same input always yields the same identicon — like a hash function.
  • 🎲 Random identicons for placeholders or testing.
  • ⚡ Built with FastAPI for speed and easy integration.

Uniqueness, Entropy & Collisions

This system can be treated like a non-cryptographic hash:

  • It is deterministic: same input → same identicon.
  • It is not cryptographically secure and not guaranteed unique across all inputs.

Entropy

  • Visual pattern bits: 15 bits
  • Color bits (RGB): 8 × 3 = 24 bits
  • Total entropy: 15 + 24 = 39 bits

Total Possible Identicons

  • With 39 bits of entropy, the total design space is 2³⁹ = 549,755,813,888 distinct identicons.

ℹ️ While 2³⁹ possibilities is large for UI purposes, this is far less than typical cryptographic hashes (e.g., 256 bits). Do not use identicons as security identifiers or for collision-sensitive logic.

How It Works (Conceptually)

  1. Take the input string (e.g., user_id).
  2. Derive a stable seed from it (e.g., a hash).
  3. Map parts of that seed to:
    • Grid/shape decisions (15 bits)
    • Color (RGB) (24 bits total)
  4. Render the corresponding SVG/PNG.

API (Example)

  • GET /identicon?string=<string>&size=<px> → deterministic identicon for <string>.
  • GET /identicon/avatar?size=<px> → random identicon.

Use Cases

  • Default avatars for apps and dashboards
  • Placeholder images for seeded test data
  • Visual differentiation without user uploads

Notes

  • Deterministic behavior ensures a consistent avatar for each identifier (similar to GitHub).
  • Not suitable for cryptographic, authentication, or collision-intolerant applications.

About

Deterministic GitHub-style identicon generator with 39 bits of entropy (≈550M possibilities). Same input → same icon, like a hash, but not cryptographically secure.

Topics

Resources

Stars

Watchers

Forks

Languages