yomorun / hashids-java

Hashids algorithm v1.0.0 implementation in Java
http://hashids.org
MIT License
1.02k stars 156 forks source link

Relax MAX_NUMBER restriction #56

Closed iggymoran closed 6 years ago

iggymoran commented 6 years ago

I understand the desire to be completely compatible with the Javascript implementation/limitiations, as explained in #47 and in the docs, but is it possible to provide a toggle that disables this functionality?

This would ensure backward compatibility with Javascript's limitations, but would allow this library to make use of the full potential that the Java platform provides.

Other implementations (such as Scala and .Net) don't impose these restrictions and allow the library to be used with the native implementation of the number.

arcticicestudio commented 6 years ago

I've also proposed this in another issue some time ago and if I remember correctly they planed a v2 which will include some breaking changes like this, but I implemented my own library including this feature. I've found no reason to limit a Java implementation only because the reference algorithm implementation is limited by the chosen language. This library is used within the Java world and even if generated Hashids are e.g. used in a REST API to disguise internal database IDs which will be consumed by a JavaScript frontend, the part of the "decryption" will be handed in the backend (this library) while the frontend handles the Hashid as simple string and not a number.

0x3333 commented 6 years ago

The initial proposal was to be interoperable. See https://github.com/jiecao-fm/hashids-java/issues/55

arcticicestudio commented 6 years ago

Might be interesting that there is a new TC39 proposal that introduces BigInt to JavaScript, so the current limit will be kind of obsolete.

fanweixiao commented 6 years ago

@arcticicestudio I think we should follow hashids main project spec, to keep exact result in different languages.

0x3333 commented 6 years ago

I was thinking about this issue, and I believe that the best path is to allow bigger numbers when the user explicitly allow incompatibility with the original spec. This way we can have a version that follows the original implementation and also allows users to loosen up the spec a bit. Something like "strict mode", which is compatible with the original spec, and a "relaxed mode" which is more javaish.

fanweixiao commented 6 years ago

Yep, and I’d suggest a PR or Fork for this.

On Thu, May 3, 2018 at 18:05 Tercio Gaudencio Filho < notifications@github.com> wrote:

I was thinking about this issue, and I believe that the best path is to allow bigger numbers when the user explicitly allow incompatibility with the original spec. This way we can have a version that follows the original implementation and also allows users to loosen up the spec a bit. Something like "strict mode", which is compatible with the original spec, and a "relaxed mode" which is more javaish.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/jiecao-fm/hashids-java/issues/56#issuecomment-386247311, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEAQ56RLW0_4Chyoq1pE12QGdB3HcYDks5tutZSgaJpZM4TltqP .

-- Sent from Gmail Mobile