View Source ShortUUID (ShortUUID v4.0.0)

ShortUUID is a module for encoding and decoding UUIDs using a base57 alphabet.

Functions

  • encode/1 - Encodes a UUID into a shorter string using base57 alphabet
  • encode!/1 - Same as encode/1 but raises an error on failure
  • decode/1 - Decodes a shortened string back into a UUID
  • decode!/1 - Same as decode/1 but raises an error on failure

Example

iex> ShortUUID.encode("550e8400-e29b-41d4-a716-446655440000")
{:ok, "H9cNmGXLEc8NWcZzSThA9S"}

iex> ShortUUID.decode("H9cNmGXLEc8NWcZzSThA9S")
{:ok, "550e8400-e29b-41d4-a716-446655440000"}

For custom alphabets and more options, see ShortUUID.Builder.

Summary

Functions

decode(string)

@spec decode(String.t()) :: {:ok, String.t()} | {:error, String.t()}

decode!(string)

@spec decode!(String.t()) :: String.t() | no_return()

encode(uuid)

@spec encode(String.t()) :: {:ok, String.t()} | {:error, String.t()}

encode!(uuid)

@spec encode!(String.t()) :: String.t() | no_return()