Small · Sortable · Secure ID generator
Pikaid is a 26-character, lowercase Base36 identifier composed of a 7-character timestamp and a 19-character cryptographically secure randomness. It provides a modern, compact alternative to UUID and ULID, with built-in lexicographical sortability and strong collision resistance.
Full specifications and other information are avalible at pikaid/pikaid-specs.
- PHP 7.4 or higher
- ext-bcmath or ext-gmp (optional, recommended for performance)
Install via Composer:
composer require pikaid/pikaid-php
Then include Composer's autoloader in your project:
require 'vendor/autoload.php';
<?php
use Pikaid\Pikaid;
// Generate a new Pikaid
$id = Pikaid::generate();
echo "New ID: $id\n"; // e.g. 0swct4q01ch83h91onl6l47vb6
// Validate an existing ID
if (Pikaid::isValid($id)) {
echo "ID is valid!\n";
} else {
echo "Invalid ID format.\n";
}
// Parse a Pikaid into its components
try {
$result = Pikaid::parse($id);
/** @var DateTimeImmutable $timestamp */
$timestamp = $result['timestamp'];
$randomHex = $result['randomness'];
echo "Created at: " . $timestamp->format('Y-m-d H:i:s') . " UTC\n";
echo "Randomness (hex): $randomHex\n";
} catch (InvalidArgumentException $e) {
echo "Error: " . $e->getMessage() . "\n";
}
Generates a new 26-character Pikaid.
Checks whether the given string matches the Pikaid format.
Parses a Pikaid into:
timestamp
:DateTimeImmutable
(UTC)randomness
:string
(hex representation)
Throws InvalidArgumentException
if the format is invalid.
Pikaid is released under the MIT License.