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

Support generating numeric hashIDs #23

Closed
abonander opened this issue Oct 22, 2021 · 1 comment · Fixed by #24
Closed

Support generating numeric hashIDs #23

abonander opened this issue Oct 22, 2021 · 1 comment · Fixed by #24

Comments

@abonander
Copy link

abonander commented Oct 22, 2021

I wanted to configure harsh to encode IDs using only 0-9 so it still looks like a number, but got BuildError::AlphabetLength from HarshBuilder::build() when I tried to pass an alphabet of "0123456789".

Is there any particular reason why it requires that the alphabet be at least 16 characters? There's no comments about it in the source. If there is one, it should probably be documented on HarshBuilder::alphabet().

@archer884
Copy link
Owner

You know, I'm not 100% sure. I have always made the assumption that the values are encoded as a randomized hex-like dialect, which would require a minimum of sixteen "numerals," but I don't know that to be the case. It certainly seems to be a hex-like encoding. It is possible that the algorithm itself could support a smaller alphabet, but I worry that would break compatibility with other implementations.

I did a quick search to see if I could find the original reason and it appears that the reason is NOT related to hexadecimal. Rather, it has to do with the way multiple numbers can be encoded into a single string, and with the author's desire to prevent any vulgar language randomly showing up in identifiers.

I can certainly add a note about the minimum alphabet size.

Good question!

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

Successfully merging a pull request may close this issue.

2 participants