2017 © Pedro Peláez
 

library bijective-shortener

A Clean Bijective Base Converter for PHP

image

reshadman/bijective-shortener

A Clean Bijective Base Converter for PHP

  • Sunday, March 15, 2015
  • by bigsinoos
  • Repository
  • 1 Watchers
  • 2 Stars
  • 1,968 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 2 % Grown

The README.md

Php Bijective Shortener

This package is a bijective shortener which shortens your unique integer identifier(like a mysql auto increment key) to a unique short string, the strategy simply makes a number with a longer base., (*1)

Usage

You can set the characters which you want to be included into the shortened string, by default a random string is set. You should note that this is not an encrypting solution it's just an encoding solution like base_64 but in a bigger base, but by making a random sort of allowed characters you can gaurantee that it is impossible to guess a long number given a shortened string., (*2)

<?php
use \Reshadman\BijectiveShortener\BijectiveShortener;

BijectiveShortener::setChars(
    'YRCAtS2qcL06JzFeWIsf9HbwgVPUoOkrZpaGm47vjNEuMT1dynlDxXhQK8i5B3'
);

$shortened = BijectiveShortener::makeFromInteger($int = 60500);

$decoded = BijectiveShortener::decodeToInteger($shortened);

echo 'The Shortened version of ' . $int ' is' . $shortened '\n';
echo 'The decoded version of ' . $shortened ' is ' . $decoded ' which is equal to original number(' . $int ')';

The Versions

15/03 2015

dev-master

9999999-dev

A Clean Bijective Base Converter for PHP

  Sources   Download

The Development Requires

by Reza Shadman

15/03 2015

1.0

1.0.0.0

A Clean Bijective Base Converter for PHP

  Sources   Download

The Development Requires

by Reza Shadman