Open sdavids opened 1 month ago
@ericelliott Maybe you could provide an authoritative assessment?
I opened this issue because I considered doing a 1:1 algorithm translation in a new repo but I think it would be better to update this project instead of creating a new one.
Correct that %
is not a safe method to generate uniform random values. Are the histogram and randogram tests run in this repo?
Describe the bug
I am unsure if this implementation is the same algorithm as the original.
To Reproduce
The entropy is computed differently:
https://github.com/paralleldrive/cuid2/blob/53e246b0919c8123e492e6b6bbab41fe66f4b462/src/index.js#L7-L14
https://github.com/thibaultmeyer/cuid-java/blob/c55aa797b13348a01ad1a059fe88a5af1c613e8f/src/main/java/io/github/thibaultmeyer/cuid/CUID.java#L265-L275
The hash is computed differently:
https://github.com/paralleldrive/cuid2/blob/53e246b0919c8123e492e6b6bbab41fe66f4b462/src/index.js#L31-L35
https://github.com/thibaultmeyer/cuid-java/blob/c55aa797b13348a01ad1a059fe88a5af1c613e8f/src/main/java/io/github/thibaultmeyer/cuid/CUID.java#L283-L292
The alphabet is accessed differently:
https://github.com/paralleldrive/cuid2/blob/53e246b0919c8123e492e6b6bbab41fe66f4b462/src/index.js#L37-L39
https://github.com/thibaultmeyer/cuid-java/blob/c55aa797b13348a01ad1a059fe88a5af1c613e8f/src/main/java/io/github/thibaultmeyer/cuid/CUID.java#L69
https://github.com/ai/nanoid?tab=readme-ov-file