ShortUUID v0.1.0 ShortUUID

ShortUUID is a simple UUID shortener library.

Installation

  1. Add ShortUUID to your list of dependencies in mix.exs:

    def deps do
      [{:shortuuid, "~> 0.1.0"}]
    end
  2. Optionally configure the alphabet to be used for encoding in config.exs:

      config :shortuuid,
        alphabet: "23456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"

    The default alphabet (above) will translate UUIDs to base57 using lowercase and uppercase letters and digits while avoiding similar-looking characters such as l, 1, I, O and 0.

Typical usage

Use ShortUUID to shorten UUID strings generated by other libraries such as Ecto, Elixir UUID and Erlang UUID.

Acknowledgments

This project was inspired by skorokithakis/shortuuid.

Link to this section Summary

Functions

Convert a shortened UUID back to a full size UUID

Encode a UUID using the chosen alphabet

Link to this section Functions

Link to this function decode(string)
decode(String.t) :: String.t

Convert a shortened UUID back to a full size UUID.

Examples

iex> ShortUUID.decode("keATfB8JP2ggT7U9JZrpV9")
"2a162ee5-02f4-4701-9e87-72762cbce5e2"
Link to this function encode(uuid)
encode(String.t) :: String.t

Encode a UUID using the chosen alphabet.

Examples

iex> ShortUUID.encode("2a162ee5-02f4-4701-9e87-72762cbce5e2")
"keATfB8JP2ggT7U9JZrpV9"