Skip to content

tgrk/humanids

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HumanIDs

Hex pm Hex Docs Build Status Coverage Status License

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-42
  • curious-foxes-7
  • jazzy-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.2.0"}
  ]
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.

About

Generate Human Readable IDs

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages