seym0n/angry-purple-tiger

Generate memorable, human-readable animal-based hash digests for PHP applications

Maintainers

Package info

github.com/Seym0n/angry-purple-tiger

pkg:composer/seym0n/angry-purple-tiger

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2025-10-29 10:18 UTC

This package is auto-updated.

Last update: 2026-03-29 01:13:52 UTC


README

Generate memorable, human-readable animal-based hash digests for PHP applications.

This is a PHP port of Helium's angry-purple-tiger library, which generates animal-based hash digests meant to be memorable and human-readable. Perfect for anthropomorphizing project names, crypto addresses, UUIDs, and other complex strings in user interfaces.

Packagist Version Packagist Stars Packagist Downloads

Installation

Install via Composer:

composer require seym0n/angry-purple-tiger

Usage

Basic Example

<?php

use Seymon\AngryPurpleTiger\Generate;

$generator = new Generate();
$digest = $generator->animalHash('my ugly input string');
echo $digest;
// Output: Rapid Grey Rattlesnake

Custom Separator

$digest = $generator->animalHash('my ugly input string', 'titlecase', '-');
echo $digest;
// Output: Rapid-Grey-Rattlesnake

Different Styles

// Lowercase
$digest = $generator->animalHash('my ugly input string', 'lowercase');
echo $digest;
// Output: rapid grey rattlesnake

// Uppercase
$digest = $generator->animalHash('my ugly input string', 'uppercase');
echo $digest;
// Output: RAPID GREY RATTLESNAKE

// Titlecase (default)
$digest = $generator->animalHash('my ugly input string', 'titlecase');
echo $digest;
// Output: Rapid Grey Rattlesnake

API

animalHash($input, $style = 'titlecase', $separator = ' ')

Generates an animal-based hash from the input string.

Parameters:

  • $input (string, required): The string to hash
  • $style (string, optional): Output style - 'titlecase', 'lowercase', or 'uppercase'. Default: 'titlecase'
  • $separator (string, optional): Character(s) to separate words. Default: ' ' (space)

Returns:

  • (string): A three-word animal-based hash in the format: adjective color animal

Throws:

  • \Exception: If an unknown style is provided

How It Works

The library:

  1. Generates an MD5 hash of the input string
  2. Converts the hash into bytes
  3. Compresses the bytes into 3 values using XOR operations
  4. Uses these values as indices to select words from three lists:
    • 256 adjectives
    • 256 colors
    • 256 animals
  5. Formats and returns the three words according to the specified style and separator

Testing

Run the test suite with PHPUnit:

composer install
vendor/bin/phpunit

License

Apache 2.0

Original library © 2018 Helium Systems, Inc. PHP port by Simon

Credits

This is a PHP port of the original JavaScript library angry-purple-tiger by Helium Systems, Inc.