Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there any way to generate a more user friends oid from Noray? #44

Closed
Ughuuu opened this issue Nov 26, 2023 · 2 comments
Closed

Is there any way to generate a more user friends oid from Noray? #44

Ughuuu opened this issue Nov 26, 2023 · 2 comments

Comments

@Ughuuu
Copy link

Ughuuu commented Nov 26, 2023

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.

@Ughuuu
Copy link
Author

Ughuuu commented Nov 26, 2023

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

@elementbound
Copy link

Done in #48, thanks for the contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants