Skip to content

Latest commit

 

History

History
77 lines (55 loc) · 2.5 KB

README.md

File metadata and controls

77 lines (55 loc) · 2.5 KB

AlphaID.js - Convert any integer to a short alphanumeric version

Release Tests Build License Downloads

AlphaID.js

AlphaID.js is a library that let you convert any integer to a short alphanumeric version. It can be useful for generating short, unique, and obfuscated identifiers.

AlphaID Library Versions

These versions should all function harmoniously, allowing for encoding in one language and decoding in another.

Installation

You can install AlphaID.js using npm:

npm i alpha-id-js

Via CDN:

<script src="https://unpkg.com/alpha-id-js"></script>

Getting Started

Simple usage looks like:

const AlphaID = require('alpha-id-js');
// or from browser ->  <script src="https://unpkg.com/alpha-id-js"></script> 

const encodedString = AlphaID.convert(258456357951);
console.log(encodedString);
// Output: '4y7exoH'

const originalNumber = AlphaID.recover('4y7exoH');
console.log(originalNumber);
// Output: 258456357951

Configuring a Global Key

You can set a global key that will be used for encoding and decoding if no specific key is provided. This can be done using the config method:

const AlphaID = require('alpha-id-js');

AlphaID.config('my_key');

const encodedString = AlphaID.convert(258456357951);
console.log(encodedString);
// Output: '4ymMZq9'

const originalNumber = AlphaID.recover('4ymMZq9');
console.log(originalNumber);
// Output: 258456357951

License

AlphaID is open-source software licensed under the MIT license.