HumanIDs
HumanIDs is a small Elixir library for generating human-readable IDs from random words plus a numeric suffix. The output is easier to read, say aloud, and share than opaque identifiers.
Examples:
nimble-otters-42curious-foxes-7jazzy-platypuses-100
These IDs are human-friendly, not secure. Do not use them as your primary database key or as a security-sensitive token.
Installation
Add humanids to your dependencies in mix.exs:
def deps do
[
{:humanids, "~> 0.1.1"}
]
endThen fetch dependencies with:
mix deps.getUsage
Generate a default three-part ID:
iex> HumanIDs.generate()
"nimble-otters-42"
Increase the total number of segments with :segments:
iex> HumanIDs.generate(segments: 4)
"curious-gazelles-dragons-7"
By default, HumanIDs combines random words from built-in adjective and noun lists, then appends a number from 1 to 100.
Development
Install dependencies:
mix deps.getRun the test suite:
mix testFormat, check coverage, and run static analysis:
mix format
mix coveralls
mix dialyzerCI also enforces warning-free compilation and formatted code:
mix compile --warnings-as-errors
mix format --check-formattedBenchmarking
The repository includes a Benchee benchmark at benchmark/default.exs. Run it with:
mix run benchmark/default.exsLicense
Released under the Apache 2.0 license. See LICENSE.