HumanIDs

Hex pmHex DocsBuild StatusCoverage StatusLicense

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:

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"}
  ]
end

Then fetch dependencies with:

mix deps.get

Usage

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.get

Run the test suite:

mix test

Format, check coverage, and run static analysis:

mix format
mix coveralls
mix dialyzer

CI also enforces warning-free compilation and formatted code:

mix compile --warnings-as-errors
mix format --check-formatted

Benchmarking

The repository includes a Benchee benchmark at benchmark/default.exs. Run it with:

mix run benchmark/default.exs

License

Released under the Apache 2.0 license. See LICENSE.