You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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().
The text was updated successfully, but these errors were encountered:
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.
I wanted to configure
harsh
to encode IDs using only 0-9 so it still looks like a number, but gotBuildError::AlphabetLength
fromHarshBuilder::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()
.The text was updated successfully, but these errors were encountered: