UUID Encoder
Convert UUIDs into Base32, Base36, or any other encoding of your choice.
Usage
const UuidEncoder = ; // Create Base 36 encoderconst encoder = 'base36'; // Encode an UUIDconst encodedUuid = encoder; // Decode an encoded UUIDconst decodedUuid = encoder;
API
UuidEncoder([baseEncodingStr = 'base36'])
Instantiate a new encoder using the specified base encoder.
string encode(string uuid)
Returns a string containing the encoded version of the uuid
.
string decode(string str)
Returns a string containing the decoded UUID from str
.
Encoding
Built-In Encodings
Type | Charset | Description |
---|---|---|
'base2' |
0-1 | Binary encoding |
'base10' |
0-9 | Decimal encoding |
'base16' |
0-9, a-f | Hexadecimal encoding |
'base32' |
Custom | Crockford's Base 32 |
'base36' |
0-9, a-z | Base 36 (default) |
'base58' |
Custom | Bitcoin Base 58 |
'base62' |
0-9, A-Z, a-z | Base 62 |
'base64' |
0-9, A-Z, a-z, +, / | Base 64 |
'base64url' |
0-9, A-Z, a-z, -, _ | Base 64 URL encoding (RFC 4648) |
Custom Encoding
To use a different set or count of encoding characters, simply pass a string containing every desired letter to the constructor.
All custom encoding sets are case sensitive.
const encoder = '02468ACEGI'; // weird base10