Closed Ughuuu closed 9 months ago
Upon closer investigation, it seems the code that generates the id is in: host.entity.mjs
and it calls nanoid
. From their docs it seems nanoid accepts a parameter that tells it what length to generate the id(knowing that you might have collisions). Maybe we can have a config variable that goes into .env that defaults to 21(which is what nanoid uses by default) and also one that exposes the letters used by nanoid(which would default to useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict
which is what nanoid uses right now).
This way it would be backward compatible. Or we can make it if the env vars are empty, we set default values, this way is even safer that its backwards compatible.
And like this, users could easily override the settings and put something like:
length: 4
letters: 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ
Done in #48, thanks for the contribution!
Right now, Noray gives an oid string like: 11abcdefABcdAbcAbC1AB
Is there any way to generate one with only 4 character? or 5? What is the algorithm used by noray to generate this? If it would be 4 characters only letter and numbers, that would be a lot of combinations I feel like.
If we had numbers + big letters: 36. 36^4 = 1679616 If we had numbers + big and small letters, 62. 62^4 = 14776336 And if these are reused, then it's more than enough for my use case for example and would be easier for users also to transmit this shorter code. The only thing would be to make absolutely sure that these are generated without duplicates unless they all run out(eg 1,2,3..99 and not 1,2,2,5,2,..,99). Even though not great if it were in order, wouldn't be the worst also.