定制 seym0n/angry-purple-tiger 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

seym0n/angry-purple-tiger

最新稳定版本:v1.0.0

Composer 安装命令:

composer require seym0n/angry-purple-tiger

包简介

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

README 文档

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.

统计信息

  • 总下载量: 1
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2025-10-29