Comments (5)
I'm not sure that I see any benefit to this since you could just create the alphabet string from an array.
alphabet = ['a1', 'b2', 'c3', 'd4', 'e5', 'f6', 'g7', 'h8']
hashids = Hashids.new("this is my salt", 0, alphabet.join)
hash = hashids.encode(1) # => "g5"
I'd prefer not to change the behavior of this package too much, especially not the public API.
EDIT: Ah, now I understand what you meant, that you want to substitute 1 character for n-characters, but that would defeat the purpose of this package and algorithm (and break compatibility with all other hashids implementations)
from hashids.rb.
Thanks for quick reply 💯
- for example, I want to use sequence of chars like:
['a1', 'a2', 'b1', 'b2']
. In current realization it will be like:'a1a2b1b2'
or just'ab12'
. In this case, we'll have something likeaab2
insteada1b1
- It should be optional (I forgot to add it, sorry)
from hashids.rb.
I will not consider anything that would break compatibility with the http://hashids.org/ specification.
from hashids.rb.
okay, I got your point. Thanks, I'll close the issue 💗
from hashids.rb.
I would anticipate such a feature. There is a big problem when you generated public ids: how to remove or to skip bad words/phrases, including all the slang and the live nature of the language.
One of the best solutions, imo, which does not need curse words dictionaries/NLP analysis and which works well is to have a predefined safe alphabet like A0
, B5
and so on so any combination is never a bad word.
Don't see why alphabet can not be an array of strings instead of array of characters?
from hashids.rb.
Related Issues (16)
- Is this thread-safe? HOT 3
- Please, ship a new version with Ruby 2.4.0 support HOT 2
- Duplicate hashids HOT 1
- Support for 0.3.0
- Duplicate Hash Values HOT 3
- Hash collision HOT 3
- Not compatible with frozen strings HOT 1
- Possibility to encrypt negative numbers HOT 3
- Validate salt length?
- Support for UUID? HOT 1
- Is this project actively maintenance? HOT 1
- MIN_ALPHABET_LENGTH is incorrect HOT 2
- Validate alphabet before decoding HOT 1
- protected method `encode' called for #<Hashids> HOT 4
- Make the usage more easy HOT 2
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.rb.