vinkla / laravel-hashids

A Hashids bridge for Laravel
MIT License
2k stars 173 forks source link

Duplicate Hash IDs? #161

Closed carnevalle closed 2 years ago

carnevalle commented 2 years ago

I am using Laravel 9 and laravel-hashids 10 and I have this case where it generates duplicate Hash ID's

 // Config
'test' => [
    'salt' => 'test',
    'length' => 10,
]

 // Code
return [
    '134714' => \Hashids::connection('test')->encode(134714),
    '134758' => \Hashids::connection('test')->encode(134758),
    \Hashids::connection('test')->encode(134714) => \Hashids::connection('test')->decode(\Hashids::connection('test')->encode(134714)),
];

Output

{
  "134714": "b0ayYOOKay",
  "134758": "b0ayYOGKay",
  "b0ayYOOKay": [
    134714
  ]
}
vinkla commented 2 years ago

The hashes are not the same.

carnevalle commented 2 years ago

Oh, I see it now. The real case produces these:

"134714": "OorV7xpLLg72dRj",
"134758": "OorV7xpLlg72dRj",

I guess my problem is case insensitivity somewhere.

vinkla commented 2 years ago

I guess my problem is case insensitivity somewhere.

Yes.