ngubin/key-n

Generation a unique short key from the number.

Maintainers

Details

github.com/ngubin/key-n

Source

Issues

Installs: 9

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/ngubin/key-n

v1.0 2020-07-09 01:40 UTC

This package is not auto-updated.

Last update: 2025-10-11 00:43:11 UTC


README

Generating a unique short key from the number.

A simple library for converting a number into a string key and back. You can use to shorten long numbers to unique keys.

Latest Version Total Downloads

Example Usage

Creating a key from a number:

You can only encode an integer greater than or equal to one.

use KeyN\Make\Key62;

$instance = Key62::make();
$key = $instance->encode(100000);

Set your own character set to create keys:

use KeyN\Make\Key62;

$characters = 'wWpJbH8nIDed1Evq5OcToF2ZuXsayz7RrtP490ixSKC3GM6gYkNVhBUQmLlfAj';

$instance = Key62::make($characters);
$key = $instance->encode(100000);

Getting the number from the key:

You can decode the key if all of its characters are in the class set.

use KeyN\Make\Key62;

$instance = Key62::make();
$number = $instance->decode('Gh1a');

License

This project is released under the MIT License.

© 2020 Nik Gubin, All rights reserved.