anscd / shape-hash
A library to generate deterministic SVG images from strings.
Requires
- php: >=7.4
This package is auto-updated.
Last update: 2026-03-18 16:21:29 UTC
README
A deterministic hash visualization tool inspired by the "Hash Visualization: a New Technique to improve Real-World Security" paper by Perrig and Song.
Purpose
ShapeHash converts any input string into a unique, deterministic SVG image. It uses an SHA-256 based PRNG to ensure that the same input string always produces the exact same visualization. The resulting image is a circular composition of overlapping basic shapes (triangles, squares, and circles) with varying colors and opacities, designed to be easily distinguishable by humans.
Features
- Deterministic: Same input always yields the same image.
- Visual Clarity: Uses a 20-color palette with contrast checks to ensure distinct shapes.
- Zero Dependencies: Pure PHP implementation with no external libraries or extensions required for SVG generation.
- CLI Interface: Easy to use from the command line.
Installation
No installation or dependencies are required. Ensure you have PHP installed on your system.
Usage
Run the script from your terminal:
php hash.php "your input string"
Options
-o, --outfile <path>: Specify the output file path (default:out.svg).-h, --help: Show help information.
Examples
Generate a visualization for "Hello World":
php hash.php "Hello World" -o hello.svg
Generate a visualization with the default output name (out.svg):
php hash.php "unique identity"
Requirements
- PHP 7.4 or higher (for
hash()andunpack()functions).
Credits
Visualizations inspired by beautiful circles from https://github.com/danfinlay/jazzicon