vinkla / hashids

A small PHP library to generate YouTube-like ids from numbers. Use it when you don't want to expose your database ids to the user.
https://hashids.org/php
MIT License
5.28k stars 418 forks source link

wiill a same number get the same result for different salts? #135

Closed videni closed 4 years ago

videni commented 4 years ago

As long as you don't change constructor arguments midway, the generated output will stay unique to your salt

does this mean a same number might get the same result for different salts?

vinkla commented 4 years ago

Not as long as you don't change constructor arguments midway, the generated output will stay unique to your salt.

barnabaskecskes commented 4 years ago

@vinkla @videni I've just encountered an exception for that when using very long salts. It is probably not a bug just something to keep an eye out for...

Screenshot 2020-02-27 at 14 19 10

Context: I'm using this package to obscure resource IDs in some systems, constructing the hash dynamically as "{$fullyQualifiedResourceClassName}::{$saltFromConfig}" and just stumbled upon this in a larger app where there is a fairly deep folder structure.