shorten-uuid
v1.0.2
Published
Shorten UUID to a string of length 24 witch applicable to the URL and WeChat QR code.
Downloads
42
Maintainers
Readme
shorten-uuid
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