yomorun / hashids-java

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

Same hash output for different input #62

Closed Ladret closed 5 years ago

Ladret commented 5 years ago

Hi,

I have a problem with my code generating the same hash for two separate inputs.

Heres my code:

Hashids bookingHashIds = new Hashids("Booking Salt", 8);
System.out.println(bookingHashIds.encode(8250));
System.out.println(bookingHashIds.encode(8294));

Output is:

RqkpK7mW Rqkpk7mW

This doesn't seem quite right?

0x3333 commented 5 years ago

Nope, they are different, take a look at the letter k right before number 7, they are different, upper and lower case. Hashids are case sensitive.

If you don't want to have this, you can provide a different alphabet, like:

Hashids bookingHashIds = new Hashids("Booking Salt", 8, "abcdefghijklmnopqrstuvwxyz1234567890");
System.out.println(bookingHashIds.encode(8250));
System.out.println(bookingHashIds.encode(8294));
5qd18kqx
1pxz6zq8
Ladret commented 5 years ago

Ok, sorry, I missed that, I double checked before posting but could not see the difference.. My apologies.