An open API service indexing awesome lists of open source software.

https://github.com/ajaxray/short-code

ShortCode generator for PHP. Create short, reversible or random, hash like codes.
https://github.com/ajaxray/short-code

hash php php-library shortcode

Last synced: about 2 months ago
JSON representation

ShortCode generator for PHP. Create short, reversible or random, hash like codes.

Awesome Lists containing this project

README

        

# ShortCode

[![SensioLabsInsight](https://insight.sensiolabs.com/projects/8254062e-538a-4667-aa56-920e293bef5a/small.png)](https://insight.sensiolabs.com/projects/8254062e-538a-4667-aa56-920e293bef5a)
[![Build Status](https://travis-ci.org/ajaxray/short-code.svg?branch=master)](https://travis-ci.org/ajaxray/short-code)
[![Coverage Status](https://coveralls.io/repos/ajaxray/short-code/badge.svg?branch=master&service=github)](https://coveralls.io/github/ajaxray/short-code?branch=master)
[![Latest Stable Version](https://poser.pugx.org/ajaxray/short-code/v/stable)](https://packagist.org/packages/ajaxray/short-code)
[![Total Downloads](https://poser.pugx.org/ajaxray/short-code/downloads)](https://packagist.org/packages/ajaxray/short-code)
[![License](https://poser.pugx.org/ajaxray/short-code/license)](https://packagist.org/packages/ajaxray/short-code)

ShortCode generator for PHP. Create short, hash like codes. Codes can be random or reversible. Output format is customizable (see the list below).
You can generate random string code of your desired character length, e.g. 4, 6, 8 ... up to 20.
Also, you can generate reversible codes from numbers. It's useful when you'll need to trace the original number from a reference code string.

Can be used for generating small reference codes, tiny URLs or any other purpose.

## Installation

Install the latest version with

```
$ composer require ajaxray/short-code
```

## Supported Output and Conversion Formats

- `ShortCode\Code::FORMAT_ALNUM` : (Default) Alphanumaric characters. includes 0-9, a-z and A-Z
- `ShortCode\Code::FORMAT_ALNUM_CAPITAL` : Alphanumaric characters. includes 0-9 and A-Z
- `ShortCode\Code::FORMAT_ALNUM_SMALL` : Alphanumaric characters. includes 0-9 and a-z
- `ShortCode\Code::FORMAT_CHAR_CAPITAL` : Capital letter characters. includes only A-Z
- `ShortCode\Code::FORMAT_CHAR_SMALL` : Small letter characters. includes only a-z
- `ShortCode\Code::FORMAT_NUMBER` : Numbers. includes only 0-9. Can be used for random number generation

## Generating Random Code

```php
"This is the Book about which there is no doubt, a guidance for those conscious of Allah" - [Al-Quran](http://quran.com)