Skip to content

bryannielsen/tiny-php

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Coverage Status

Tiny

A reversible base62 ID obfuscater

Authors

Originally by Jacob DeHart, with Ruby and Python ports by Kyle Bragger

Now maintained by Zack Kitzmiller.

Installation

Install via Composer

{
    "require": {
        "zackkitzmiller/tiny": "1.1.0"
    },
}

Usage

$tiny = new \ZackKitzmiller\Tiny('5SX0TEjkR1mLOw8Gvq2VyJxIFhgCAYidrclDWaM3so9bfzZpuUenKtP74QNH6B');

echo $tiny->to(5);
// E

echo $tiny->from('E');
// 5

Configuration

You must instanciate a new instance of Tiny with a random alpha-numeric set where each character must only be used exactly once. Do NOT change this once you start using Tiny, as you won't be able to reverse.

Using laravel?

If you're using laravel and want to use a more laravel-like and cleaner syntax you only have to follow these steps.

First open your app/config/app.php file and scroll down to your providers and add

'providers' => array(
    ...
    'ZackKitzmiller\TinyServiceProvider',
)

and then this to aliases

'aliases' => array(
    ...
    'Tiny' => 'ZackKitzmiller\Facades\Tiny',
)

Lastly you run php artisan config:publish zackkitzmiller/tiny to publish the configuration file and then run php artisan tiny:generate to create a valid key.

Usage in Laravel

echo Tiny::to(5);
// echos E

echo Tiny::from('E');
// echos 5

About

A reversible base62 ID obfuscater

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%