sqids / sqids-javascript

Official JavaScript port of Sqids. Generate short unique IDs from numbers.
https://sqids.org/javascript
MIT License
679 stars 14 forks source link

Support hex #22

Closed KieronWiltshire closed 10 months ago

KieronWiltshire commented 10 months ago

Please support hex

4kimov commented 10 months ago

Hi @KieronWiltshire, unfortunately that's not in the plans for several reasons:

  1. Hex strings are common among hashes, and Sqids should not encourage encoding or obfuscating sensitive data
  2. Added complexity from having to decide how to split the hex string for encoding

However, if you have a legitimate use-case, you can always wrap the library into custom code

KieronWiltshire commented 10 months ago

The use case I have here is neither, I have UUIDs that I want to use in URL, but UUIDs are large and won't be consistent with other URLs.

Was hoping to convert UUIDs to hex, hash ID them, then reverse the process for lookups.

4kimov commented 10 months ago

Thanks for the feedback, makes sense. In this case, I think #2 from above would still apply. I'll keep an open mind and see if the community demand is there as the library progresses.

In the meantime, you could try to wrap your code with these: https://github.com/niieani/hashids.js/blob/master/src/hashids.ts#L150-L190

KieronWiltshire commented 10 months ago

@4kimov Thanks for the suggestion, appreciate the timely response on a Sunday :)