uuid icon indicating copy to clipboard operation
uuid copied to clipboard

Adding the ability to encode/decode to/from Base64 and Base32

Open asahaf opened this issue 5 years ago • 9 comments

I've found myself encoding the UUID to Base64 and Base32 string in multiple projects I worked on. Do you think it's a good idea if we add this encoding and decoding to this library or that's out of its scope? Thanks

asahaf avatar Aug 07 '19 16:08 asahaf

What's the use case? I personally never seen it encoded anything but binary or hex-string.

zerkms avatar Aug 13 '19 03:08 zerkms

One use case is when I use UUIDs in URLs. Base64 produces shorter string representation. in case I need shorter case-insensitive UUID string I use Base32.

asahaf avatar Aug 13 '19 10:08 asahaf

Equivalent functionality is https://www.npmjs.com/package/short-uuid

cameracker avatar Sep 07 '22 15:09 cameracker

Personally, I'd argue that this would be an unnecessary extension, since it would essentially be 1-line pass-through calls to base64.UrlEncoding.EncodeToString(u.Bytes()) and base32.StdEncoding.EncodeToString(u.Bytes()).

dylan-bourque avatar Sep 07 '22 16:09 dylan-bourque

I have a wrapper which uses base58, a handy middle ground which is used widely https://github.com/wolfeidau/shortuuid, as you say it is a pretty simple wrapper around existing UUID libraries.

Keen to migrate this to this library so i can try out v6 UUIDs.

wolfeidau avatar Nov 05 '23 00:11 wolfeidau