Git Product home page Git Product logo

tiny-php's Introduction

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.2.0"
    },
}

Usage

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

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

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

echo $tiny->to(126);
// XX

echo $tiny->from('XX');
// 126

echo $tiny->to(999);
// vk

echo $tiny->from('vk');
// 999

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.

You can generate a random set from the commandline with $ ./bin/genset

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(999);
// echos vk

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.