3 ms·
Hashids does this (avoid bad words) if anyone is curious to see an implementation > algorithm tries to avoid generating most common English curse words by neve
by corobo 5y ago
Hashids does this (avoid bad words) if anyone is curious to see an implementation
> algorithm tries to avoid generating most common English curse words by never placing the following letters (and their uppercase equivalents) next to each other:
> c, s, f, h, u, i, t
https://hashids.org/#how-does-it-work https://hashids.org/#how-does-it-work
E: ah it was already mentioned later on, hadn't got that deep into the comments yet!
- cratermoon 5y agoOh yes, there's plenty of ways to avoid curse words, but each one has a cost, and if the system needs to generate ids very quickly, any scheme that works too hard could be a bottleneck. The naive way of just randomly throwing together letters of the alphabet will eventually generate a forbidden word. Any steps taken to reduce the probability should understand the time/space tradeoffs.