Comments (4)
I haven't looked at the algorithm in a while but you can check it here: https://hashids.org/
Different salts with the same integer input will have different outputs. Different salts with any arbitrary input will have duplicate outputs at some point as far as I know, and you can test this by decoding encoded hashes with different salts. This should be rare though.
If you already have your categories set then you can do a quick test by generating a 100k values for each and see if any duplicates show up. If you have enough unique IDs to work with then you might not have to worry about it.
from hashids.net.
I am not sure either tbh, but I would guess that the outputs can contain duplicate values in that scenario.
But why not just let salt remain the same and pass in the category as the first value and the "id" be the second. [1, 4]
to generate a short id?
from hashids.net.
Thanks for the reply both, will take a look at generating a large number of IDs to check for clashes.
Our category is a string value so not sure we could use it as an additional encode value.
If we start running into clashes we can always prefix the generated hashID with something to scope them.
Appreciate we're using it for ID generation rather than ID obfuscation 👍
from hashids.net.
@ckpearson Ok, I'm obviously not informed into your details enough to really know, but from sound of it, you're trying to use Hashids for a task that it might not be best suited for... but with that said;
I would still recommend you to have an integer id stored together with your data that you can use hashids with to encode. That's what the library is for, not generating id:s.
from hashids.net.
Related Issues (20)
- Optimization: decode a single ID without allocating an array HOT 4
- how to Creates short unique ids from integers. (only positive numbers & zero) HOT 1
- Bug on long encoding with 16 alphabet chars HOT 8
- Using multiple options for encoding/decoding HOT 1
- Attempting to Decode short strings results in incorrect exceptions being produced HOT 7
- Hashids not generating with proper minhashlength HOT 1
- HashIds not working after adding custom Output formatter HOT 2
- How do I get HashIDs of a specific length? HOT 1
- How use id with Guid/UUID/Sequential Guid HOT 1
- Insufficient Variation In Generated HashIds HOT 1
- Document the effective character limit of the salt HOT 5
- Decoding input smaller than minHashLength unhandled exceptions are thrown HOT 4
- Json support? HOT 3
- Regarding HashidsNet HOT 1
- Website seems down HOT 2
- Valid use-case for library? HOT 1
- Is this lib still being maintained? HOT 2
- Decode null string thows NullReferenceException HOT 1
- Same id generated for different integers HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hashids.net.