shorten-uuid

v1.0.2
Shorten UUID to a string of length 24 witch applicable to the URL and WeChat QR code.
id uuid short shorten shorter url qrcode qr encode and 2 more...

shorten-uuid

npm bundle size npm downloads license

github build coverage

Shorten UUID to a string of length 24.

The encoded character range is -0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz.

The result is applicable to the URL and WeChat QR code.

Installation

NPM

npm install shorten-uuid
import shortenUuid from 'shorten-uuid';

Browser

Direct <script> include

<script src="https://cdn.jsdelivr.net/npm/shorten-uuid"></script>

Usage

const characters = '-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz' // default value
const { encode, decode } = shortenUuid(characters);

const uuid = '2358e803-12d4-4741-8432-63e9137bd39b';
const encoded = encode(uuid); // -> 1CNDV20AJ3S07Fm5Ed0CvCDQ
decode(encoded); // -> 2358e803-12d4-4741-8432-63e9137bd39b
npm i shorten-uuid

Metadata

  • MIT
  • Whatever
  • Cweili
  • released 3/23/2021

Downloads

Maintainers